Skip to content

Instantly share code, notes, and snippets.

@denyago
Created December 13, 2012 10:53
Show Gist options
  • Save denyago/4275692 to your computer and use it in GitHub Desktop.
Save denyago/4275692 to your computer and use it in GitHub Desktop.
Compilation of performance of comparations
      user     system      total        real
Date 38.260000   0.290000  38.550000 ( 39.010656)
Bool  2.180000   0.000000   2.180000 (  2.197462)
=> [ 38.260000   0.290000  38.550000 ( 39.010656)
,
  2.180000   0.000000   2.180000 (  2.197462)
]
require 'benchmark'
DATE = ( Time.now - 1.months)
date_tnc = Time.now
t = (1.year * 0.667).to_i
Benchmark.bm do|b|
b.report("Compare Date") do
t.times { DATE < date_tnc }
end
b.report("Compare Bool") do
t.times { true == false }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment