Created
August 21, 2014 16:38
-
-
Save schneems/96c16647f43575604627 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Calculating ------------------------------------- | |
set and reset 72210 i/100ms | |
merge 32360 i/100ms | |
dup 40064 i/100ms | |
------------------------------------------------- | |
set and reset 1505441.3 (±10.3%) i/s - 7437630 in 5.001122s | |
merge 440993.4 (±13.2%) i/s - 2168120 in 5.020391s | |
dup 603567.4 (±7.9%) i/s - 3004800 in 5.011971s | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment