Sha256: cbe4cc09c8c9cfd30aa926037d1a59447ad9f178aa2a9fb6bd303e5b86805fbe

Contents?: true

Size: 427 Bytes

Versions: 21

Compression:

Stored size: 427 Bytes

Contents

def yield_or_eval_test &block
  block.yield_or_eval 'foo'
end

def manual &block
  foo = 'foo'
  if block.arity > 0
    yield foo
  else
    foo.instance_eval &block
  end
end

benchmark 'Proc', :times => $times do
  report '#yield_or_eval' do 
    yield_or_eval_test { length }
    yield_or_eval_test { |foo| foo.length }
  end
  report 'manual arity check' do 
    manual { length }
    manual { |foo| foo.length }
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
visionmedia-rext-0.0.2 benchmarks/proc.rb
visionmedia-rext-0.0.3 benchmarks/proc.rb
visionmedia-rext-0.0.4 benchmarks/proc.rb
visionmedia-rext-0.0.5 benchmarks/proc.rb
visionmedia-rext-0.0.6 benchmarks/proc.rb
visionmedia-rext-0.0.7 benchmarks/proc.rb
visionmedia-rext-0.0.8 benchmarks/proc.rb
visionmedia-rext-0.1.0 benchmarks/proc.rb
visionmedia-rext-0.2.1 benchmarks/proc.rb
visionmedia-rext-0.2.2 benchmarks/proc.rb
visionmedia-rext-0.3.0 benchmarks/proc.rb
visionmedia-rext-0.3.1 benchmarks/proc.rb
rext-0.7.0 benchmarks/proc.rb
rext-0.6.2 benchmarks/proc.rb
rext-0.6.1 benchmarks/proc.rb
rext-0.6.0 benchmarks/proc.rb
rext-0.5.0 benchmarks/proc.rb
rext-0.4.1 benchmarks/proc.rb
rext-0.4.0 benchmarks/proc.rb
rext-0.3.5 benchmarks/proc.rb