Created
December 17, 2012 20:17
-
-
Save tarcieri/4321750 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
module ExampleMixin | |
def foo; 43; end | |
end | |
Benchmark.ips do |bm| | |
bm.report("without dci") { ExampleClass.new.foo } | |
bm.report("with dci") do | |
obj = ExampleClass.new | |
obj.extend(ExampleMixin) | |
obj.foo | |
end | |
end |
This file contains hidden or 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-darwin12.2.0] | |
#iterations/sec | |
without dci 3938758.7 (±1.9%) i/s - 19754280 in 5.017387s | |
with dci 537904.0 (±8.0%) i/s - 2683515 in 5.024073s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment