Created
June 30, 2016 08:41
-
-
Save takkanm/1928ee008d337883ba6191a13dad75dd 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 'benchmark' | |
module Foo | |
end | |
times = 1_000_000 | |
Benchmark.bm 30 do |r| | |
r.report 'extend' do | |
times.times do | |
o = Object.new | |
o.extend Foo | |
end | |
end | |
GC.start | |
r.report 'singleton_class include' do | |
times.times do | |
o = Object.new | |
o.singleton_class.include Foo | |
end | |
end | |
GC.start | |
r.report 'singleton_class prepend' do | |
times.times do | |
o = Object.new | |
o.singleton_class.include Foo | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment