Skip to content

Instantly share code, notes, and snippets.

@tyre
Created April 23, 2013 22:57
Show Gist options
  • Save tyre/5448149 to your computer and use it in GitHub Desktop.
Save tyre/5448149 to your computer and use it in GitHub Desktop.
require 'benchmark'
iterations = 2000000
Benchmark.bmbm do |x|
x.report('double equals') { iterations.times { true == true } }
x.report('triple equals') { iterations.times { true === true } }
end
# Rehearsal -------------------------------------------------
# double equals 0.110000 0.000000 0.110000 ( 0.110443)
# triple equals 0.160000 0.000000 0.160000 ( 0.155177)
# ---------------------------------------- total: 0.270000sec
# user system total real
# double equals 0.110000 0.000000 0.110000 ( 0.108412)
# triple equals 0.150000 0.000000 0.150000 ( 0.152184)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment