Skip to content

Instantly share code, notes, and snippets.

@arthurnn
Created February 13, 2014 14:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurnn/8976458 to your computer and use it in GitHub Desktop.
Save arthurnn/8976458 to your computer and use it in GitHub Desktop.
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
@tylermercier
Copy link

Seems a Fiber adds about 1 ms per call. Wonder what this would look like if you compared Fibers against Threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment