Created
November 10, 2011 08:17
-
-
Save lest/1354411 to your computer and use it in GitHub Desktop.
This file contains hidden or 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' | |
def method1(&block) | |
true if block | |
end | |
def method2(&block) | |
true if block_given? | |
end | |
n = 10_000_000 | |
Benchmark.bm do |x| | |
x.report { n.times { method1 {} } } | |
x.report { n.times { method2 {} } } | |
end | |
# user system total real | |
# 4.780000 0.020000 4.800000 ( 4.792239) | |
# 5.260000 0.000000 5.260000 ( 5.260888) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment