Skip to content

Instantly share code, notes, and snippets.

@judofyr
Forked from sheldonh/gist:1333653
Created November 2, 2011 13:47
Show Gist options
  • Save judofyr/1333663 to your computer and use it in GitHub Desktop.
Save judofyr/1333663 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'benchmark'
def bitmask
2 ** 32 - 1
end
def bitmask_with_assignment
overshoot = 2 ** 32
overshoot - 1
end
iterations = 10_000_000
Benchmark.bmbm do |x|
x.report('without') { iterations.times { bitmask } }
x.report('with') { iterations.times { bitmask_with_assignment } }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment