Skip to content

Instantly share code, notes, and snippets.

@phiggins
Forked from tarcieri/dci_benchmark.rb
Created December 17, 2012 20:29
Show Gist options
  • Save phiggins/4321887 to your computer and use it in GitHub Desktop.
Save phiggins/4321887 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'benchmark/ips'
class ExampleClass
def foo; 42; end
end
non_dci_object = ExampleClass.new
module ExampleMixin
def foo; 43; end
end
dci_object = Object.new
dci_object.extend(ExampleMixin)
p RUBY_DESCRIPTION
Benchmark.ips do |bm|
bm.report("without dci") do
non_dci_object.foo
end
bm.report("with dci") do
dci_object.foo
end
end
"ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]"
Calculating -------------------------------------
without dci 129417 i/100ms
with dci 130700 i/100ms
-------------------------------------------------
without dci 7413656.2 (±1.0%) i/s - 37142679 in 5.010532s
with dci 7390905.0 (±1.3%) i/s - 36988100 in 5.005453s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment