Created
April 26, 2010 22:01
-
-
Save jarib/379998 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
def foo(*args) | |
args | |
end | |
require "benchmark" | |
TESTS = 1_000_000 | |
Benchmark.bmbm do |results| | |
results.report("hash:") { TESTS.times { foo(:foo => 'bar') } } | |
results.report("2 args:") { TESTS.times { foo(:foo, 'bar') } } | |
end | |
# | |
# | |
# | |
# output: | |
# | |
# | |
# | |
# Rehearsal ------------------------------------------- | |
# hash: 2.470000 0.060000 2.530000 ( 2.559726) | |
# 2 args: 1.190000 0.010000 1.200000 ( 1.225796) | |
# ---------------------------------- total: 3.730000sec | |
# | |
# user system total real | |
# hash: 2.500000 0.060000 2.560000 ( 2.628864) | |
# 2 args: 1.200000 0.010000 1.210000 ( 1.205671) | |
# copy output | |
# Program exited with code #0 after 7.68 seconds. | |
# | |
# | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment