Skip to content
This repository
tag: 1.1.5
Fetching contributors…

Cannot retrieve contributors at this time

file 11 lines (10 sloc) 0.382 kb
1 2 3 4 5 6 7 8 9 10 11
require 'benchmark'

(ARGV[0] || 10).to_i.times do
  method = method(:to_s)
  method_proc = method.to_proc
  Benchmark.bm(30) do |bm|
    bm.report("control, 1000k to_s calls") { 1000000.times { to_s } }
    bm.report("Method.call, 1000k calls") { 1000000.times { method.call } }
    bm.report("to_proc'ed Method.call, 1000k calls") { 1000000.times { method_proc.call } }
  end
end
Something went wrong with that request. Please try again.