Sha256: 92539198112c0c2a0eb44cf97d2de53996344fb2dc4e2743d3996cae727d80ba
Contents?: true
Size: 697 Bytes
Versions: 18
Compression:
Stored size: 697 Bytes
Contents
require 'benchmark/ips' puts "Ruby #{RUBY_VERSION} at #{Time.now}" puts firstname = 'soundarapandian' middlename = 'rathinasamy' lastname = 'arumugam' def do_call(&block) block.call end def do_yield(&block) yield end def do_yield_without_block yield end existing_block = proc{} Benchmark.ips do |x| x.report("block.call") do |i| buffer = String.new while (i -= 1) > 0 do_call(&existing_block) end end x.report("yield with block") do |i| buffer = String.new while (i -= 1) > 0 do_yield(&existing_block) end end x.report("yield") do |i| buffer = String.new while (i -= 1) > 0 do_yield_without_block(&existing_block) end end x.compare! end
Version data entries
18 entries across 18 versions & 1 rubygems