Skip to content

Instantly share code, notes, and snippets.

@RobertDober
Created May 6, 2010 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RobertDober/391953 to your computer and use it in GitHub Desktop.
Save RobertDober/391953 to your computer and use it in GitHub Desktop.
require 'benchmark'
N = 200
range = 1..5000
Benchmark.bmbm do | x |
x.report "loop" do
N.times do
a = []
for i in range
a << lambda{ i }
end
end # times
end # report "loop"
x.report "each" do
N.times do
a = []
range.each do |i|
a << lambda{ i }
end
end
end
end # bmbm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment