Skip to content

Instantly share code, notes, and snippets.

@schneems
Created August 21, 2014 16:38
Show Gist options
  • Save schneems/db682addec7bd19937cf to your computer and use it in GitHub Desktop.
Save schneems/db682addec7bd19937cf to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
env = {"foo" => "bar", "bar" => "baz", "baz" => "boo", "PATH_INFO" => "foo"}
Benchmark.ips do |x|
x.report("set and reset") do
env["PATH_INFO"] = "zoo"
env
env["PATH_INFO"] = "foo"
end
x.report("merge") { env.merge("PATH_INFO" => "zoo") }
x.report("dup") { env.dup["PATH_INFO"] = "zoo"}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment