Skip to content

Instantly share code, notes, and snippets.

@wmoxam
Created October 19, 2008 05:18
Show Gist options
  • Save wmoxam/17783 to your computer and use it in GitHub Desktop.
Save wmoxam/17783 to your computer and use it in GitHub Desktop.
rb(main):008:0> a = 0
=> 0
irb(main):009:0> b = 1
=> 1
irb(main):010:0> Benchmark.bm {|x| x.report { 100000.times { a.zero? } } }
user system total real
0.030000 0.000000 0.030000 ( 0.020547)
=> true
irb(main):011:0> Benchmark.bm {|x| x.report { 100000.times { b.zero? } } }
user system total real
0.020000 0.010000 0.030000 ( 0.023609)
=> true
irb(main):012:0> Benchmark.bm {|x| x.report { 100000.times { a == 0 } } }
user system total real
0.040000 0.000000 0.040000 ( 0.035733)
=> true
irb(main):013:0> Benchmark.bm {|x| x.report { 100000.times { b == 0 } } }
user system total real
0.030000 0.000000 0.030000 ( 0.027180)
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment