Created
December 21, 2016 14:56
-
-
Save meoooh/8686d254b05d0a2ed2ccb635bf00b6d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hhash = {} | |
(0..10000000).each{ |i| hhash[i] = rand }; | |
parallel_sum = Parallel.map(hhash.each_slice(1000)) do |ele| # https://github.com/grosser/parallel | |
ele.sum{|value| value.last} | |
end.sum | |
puts parallel_sum | |
normal_sum = hhash.sum{|_,v| v} | |
puts normal_sum | |
parallel_sum == normal_sum # false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hhash = {} | |
(0..10000000).each{ |i| hhash[i] = 1 }; | |
parallel_sum = Parallel.map(hhash.each_slice(1000)) do |ele| # https://github.com/grosser/parallel | |
ele.sum{|value| value.last} | |
end.sum | |
puts parallel_sum | |
normal_sum = hhash.sum{|_,v| v} | |
puts normal_sum | |
parallel_sum == normal_sum # true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
따라서 해보실 분은 위와 같이 코드를 추가해보세요.
RORLAB 슬랙 채널 http://rorlab.slackarchive.io/question_answer/-/1479210726.000646/1482365225.000055/1482365225000055/ 에서 이야기 하고 있습니다. 빅넘버와 래셔널을 참고하세요.