Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 1.3.0
Fetching contributors…

Cannot retrieve contributors at this time

18 lines (16 sloc) 0.591 kb
require 'benchmark'
require 'delegate'
TIMES = (ARGV[0] || 1).to_i
TIMES.times {
Benchmark.bm(30) {|bm|
obj1 = ''
obj2 = Object.new
def obj2.to_str(); 'foo'; end
dele1 = SimpleDelegator.new(obj1)
dele2 = SimpleDelegator.new(obj2)
bm.report("control, direct calls, native") { 10_000_000.times { obj1.to_str }}
bm.report("SimpleDelegate wrapper, native") { 10_000_000.times { dele1.to_str }}
bm.report("control, direct calls, ruby") { 10_000_000.times { obj2.to_str }}
bm.report("SimpleDelegate wrapper, ruby") { 10_000_000.times { dele2.to_str }}
}
}
Jump to Line
Something went wrong with that request. Please try again.