public
Last active

  • Download Gist
lambda-vs-array.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
require 'benchmark'
 
Benchmark.bmbm do |x|
x.report { 1_000_000.times { lambda { } } }
x.report { 1_000_000.times { Array.new } }
end
 
__END__
 
Rehearsal ------------------------------------
2.490000 0.740000 3.230000 ( 3.238588)
0.810000 0.080000 0.890000 ( 0.888949)
--------------------------- total: 4.120000sec
 
user system total real
2.390000 0.740000 3.130000 ( 3.137138)
0.390000 0.000000 0.390000 ( 0.389827)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.