Skip to content

Instantly share code, notes, and snippets.

@bry4n
Created May 10, 2010 02:12
Show Gist options
  • Save bry4n/395586 to your computer and use it in GitHub Desktop.
Save bry4n/395586 to your computer and use it in GitHub Desktop.
user system total real
unless 0.520000 0.150000 0.670000 ( 0.677782)
if not 0.520000 0.150000 0.670000 ( 0.672080)
if ! 0.520000 0.180000 0.700000 ( 0.691658)
require 'benchmark'
interval = 1_000_000
val = false
Benchmark.bm(25) do |x|
x.report("unless") { interval.times { true unless val } }
x.report("if not") { interval.times { true if not val } }
x.report("if !") { interval.times { true if !val } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment