Created
February 13, 2014 14:57
-
-
Save arthurnn/8976458 to your computer and use it in GitHub Desktop.
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' | |
arr = (1..100).to_a | |
Benchmark.bm(20) do |x| | |
x.report("each.with_index") do | |
100_000.times do | |
arr.each_with_index do |v, i| | |
end | |
end | |
end | |
x.report("each.with_index b&") do | |
100_000.times do | |
bv = arr.each.with_index | |
arr.length.times do |i| | |
bv.next | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems a Fiber adds about 1 ms per call. Wonder what this would look like if you compared Fibers against Threads.