Created
September 4, 2014 17:13
-
-
Save Shinpeim/90235247dc05947bd7bf 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' | |
n = 500000 | |
def lm | |
lambda{1}.call | |
end | |
def bg | |
begin | |
1 | |
end | |
end | |
Benchmark.bm(7, ">total:", ">avg:") do |x| | |
x.report("lambda:") do | |
n.times {lm} | |
end | |
x.report("begin:") do | |
n.times {bg} | |
end | |
end |
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
user system total real | |
lambda: 0.440000 0.000000 0.440000 ( 0.443400) | |
begin: 0.040000 0.000000 0.040000 ( 0.040375) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment