Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created April 1, 2016 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/745c266b79882739a956d6d755de58c4 to your computer and use it in GitHub Desktop.
Save tenderlove/745c266b79882739a956d6d755de58c4 to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
class Foo
def bar; end
end
def ic_hit obj
obj.bar
end
z = Benchmark.ips do |x|
10.times do |i|
x.report "singleton #{i}" do
foo = Foo.new
foo.singleton_class
ic_hit foo
end
end
end
print "ips,"
puts z.entries.map(&:ips).join(",")
print "stddev,"
puts z.entries.map(&:ips_sd).join(",")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment