Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- threads = []
- 1.times do |i|
- threads << Thread.new do
- b = Benchmark.measure do
- code.call
- end
- puts b
- end
- end
- threads.each {|t| t.join }
- yields
- 1.470000 0.220000 1.690000 ( 1.894148)
- threads = []
- 5.times do |i|
- threads << Thread.new do
- b = Benchmark.measure do
- code.call
- end
- puts b
- end
- end
- threads.each {|t| t.join }
- yields
- 1.830000 0.270000 2.100000 ( 5.176225)
- 9.690000 1.240000 10.930000 ( 17.328003)
- 9.730000 1.250000 10.980000 ( 17.394973)
- 10.090000 1.270000 11.360000 ( 18.084461)
- 10.150000 1.290000 11.440000 ( 18.221553)
Add Comment
Please, Sign In to add comment