Skip to content

Instantly share code, notes, and snippets.

@brainopia
Created January 27, 2012 08:16
Show Gist options
  • Save brainopia/1687755 to your computer and use it in GitHub Desktop.
Save brainopia/1687755 to your computer and use it in GitHub Desktop.
benchmark change for rack
require 'benchmark/ips'
class Boo < Hash
def previous_to_hash
{}.replace self
end
def new_to_hash
Hash[self]
end
end
boo = Boo.new
Benchmark.ips do |x|
x.report('previously') { boo.previous_to_hash }
x.report('new_to_hash') { boo.new_to_hash }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment