Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Created April 3, 2013 06:14
Show Gist options
  • Save pcarrier/5298841 to your computer and use it in GitHub Desktop.
Save pcarrier/5298841 to your computer and use it in GitHub Desktop.
require 'benchmark'
def direct
end
def simple
direct
end
def stupid
def foo; end
foo
end
Benchmark.bmbm do |x|
n = 1_000_000
x.report 'direct' do n.times{direct} end
x.report 'simple' do n.times{simple} end
x.report 'stupid' do n.times{stupid} end
end
# user system total real
# direct 0.200000 0.000000 0.200000 ( 0.205748)
# simple 0.290000 0.000000 0.290000 ( 0.288481)
# stupid 2.140000 0.100000 2.240000 ( 2.238356)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment