Created
November 24, 2016 06:18
-
-
Save nobu/3315f8e9f6073221e3311828b3bd9631 to your computer and use it in GitHub Desktop.
benchmark of if and &.
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
$ ruby -rbenchmark -e 'N=1000_000;a=self;Benchmark.bm{|x| x.report("if") {N.times{a.itself if a}}; x.report("&.") {N.times{a&.itself}}}' | |
user system total real | |
if 0.060000 0.010000 0.070000 ( 0.076417) | |
&. 0.060000 0.000000 0.060000 ( 0.072385) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment