Skip to content

Instantly share code, notes, and snippets.

@bpot
Last active December 10, 2015 13:08
Show Gist options
  • Select an option

  • Save bpot/4439002 to your computer and use it in GitHub Desktop.

Select an option

Save bpot/4439002 to your computer and use it in GitHub Desktop.
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 }
bm.report("with dci") do
obj = ExampleClass.new
obj.extend(ExampleMixin)
end
end
Calculating -------------------------------------
without dci 79043 i/100ms
with dci 24489 i/100ms
-------------------------------------------------
without dci 3017563.1 (±2.6%) i/s - 15097213 in 5.006974s
with dci 558150.9 (±3.2%) i/s - 2791746 in 5.006372s
Calculating -------------------------------------
without dci 71499 i/100ms
with dci 24065 i/100ms
-------------------------------------------------
without dci 2680264.1 (±1.2%) i/s - 13441812 in 5.015815s
with dci 532601.9 (±3.6%) i/s - 2671215 in 5.021179s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment