Skip to content

Instantly share code, notes, and snippets.

/benchmark.rb Secret

Created August 27, 2015 15:33
Show Gist options
  • Save anonymous/4eed629ac7b34467cf29 to your computer and use it in GitHub Desktop.
Save anonymous/4eed629ac7b34467cf29 to your computer and use it in GitHub Desktop.
[4] pry(main)> Benchmark.ips do |x|
[4] pry(main)* x.report("freeze") { ENV["PATH_INFO".freeze] }
[4] pry(main)* x.report("unfrozen") { ENV["PATH_INFO"] }
[4] pry(main)* x.compare!
[4] pry(main)* end
Calculating -------------------------------------
freeze 4.722k i/100ms
unfrozen 4.687k i/100ms
-------------------------------------------------
freeze 4.309M (±13.4%) i/s - 20.560M
unfrozen 3.340M (±14.5%) i/s - 15.336M
Comparison:
freeze: 4309010.1 i/s
unfrozen: 3339758.2 i/s - 1.29x slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment