-
-
Save phiggins/4321887 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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