Created
December 8, 2012 22:17
-
-
Save francescoagati/4242223 to your computer and use it in GitHub Desktop.
benchmarking parallel gem with ruby 1.9.3, jruby 1.71 - process vs thread
This file contains 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
require 'benchmark' | |
require 'parallel' | |
array = (1..100000).map { rand } | |
Benchmark.bmbm do |x| | |
x.report("sort!") { Parallel.map((0..20), :in_process=>8) { array.dup.sort! } } | |
x.report("sort") { Parallel.map((0..20), :in_process=>8) { array.dup.sort! } } | |
end |
This file contains 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
ruby 1.9.3 | |
Rehearsal ----------------------------------------- | |
sort! 4.700000 0.150000 16.340000 ( 8.809903) | |
sort 5.950000 0.160000 18.070000 ( 10.327694) | |
------------------------------- total: 34.410000sec | |
user system total real | |
sort! 4.670000 0.160000 16.740000 ( 9.057902) | |
sort 4.630000 0.150000 16.540000 ( 8.920719) | |
jruby 1.7.1 | |
Rehearsal ----------------------------------------- | |
sort! 1.990000 0.030000 2.020000 ( 1.036000) | |
sort 1.370000 0.010000 1.380000 ( 0.713000) | |
-------------------------------- total: 3.400000sec | |
user system total real | |
sort! 1.600000 0.100000 1.700000 ( 0.921000) | |
sort 1.350000 0.010000 1.360000 ( 0.701000) | |
This file contains 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
require 'benchmark' | |
require 'parallel' | |
array = (1..100000).map { rand } | |
Benchmark.bmbm do |x| | |
x.report("sort!") { Parallel.map((0..20), :in_threads=>8) { array.dup.sort! } } | |
x.report("sort") { Parallel.map((0..20), :in_threads=>8) { array.dup.sort! } } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in the process mode of ruby 1.9.3 the overhead is also for serializing the return data of forked process