Sha256: c9396274dd8a9602bc6261bee53d130f832b9e8299b4c6f7285cef098faaa110
Contents?: true
Size: 410 Bytes
Versions: 14
Compression:
Stored size: 410 Bytes
Contents
require 'benchmark' class Foo def bar(a, b) a + b end def baz a + b end def a rand(1000_000) end def b rand(1000_000) end end foo = Foo.new Benchmark.bm 30 do |x| x.report 'original method' do 1000000.times do |_| foo.bar(rand(1_000_000), rand(1_000_000)) end end x.report 'shiny new method' do 1000000.times do |_| foo.baz end end end
Version data entries
14 entries across 14 versions & 1 rubygems