Skip to content

Instantly share code, notes, and snippets.

@calavera
Created October 3, 2009 11:32
Show Gist options
  • Save calavera/200601 to your computer and use it in GitHub Desktop.
Save calavera/200601 to your computer and use it in GitHub Desktop.
####################################
### INTERPRETER BEFORE THE PATCH ###
####################################
irb(main):002:0> Benchmark.bm { |x| x.report { for i in 1..5000; h = {"foo" => "foo", "bar" => "bar", "zoo" => "zoo", "baaz" => "baaz"}; end } }
user system total real
0.197000 0.000000 0.197000 ( 0.196000)
=> true
###################################
### INTERPRETER AFTER THE PATCH ###
###################################
irb(main):002:0> Benchmark.bm { |x| x.report { for i in 1..5000; h = {"foo" => "foo", "bar" => "bar", "zoo" => "zoo", "baaz" => "baaz"}; end } }
user system total real
0.221000 0.000000 0.221000 ( 0.220000)
=> true
##################################
### COMPILER BEFORE THE PATCH ###
##################################
user system total real
0.239000 0.000000 0.239000 ( 0.180000)
##################################
### COMPILER AFTER THE PATCH ###
##################################
user system total real
0.267000 0.000000 0.267000 ( 0.206000)
require 'benchmark'
Benchmark.bm do |x|
x.report {
(1..5000).each do
k = "foo"
h = {k => "foo", "bar" => "bar", "zoo" => "zoo", "baaz" => "baaz"}
k.reverse!
h[k]
end
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment