on master help sign in
text/benchmarks/ruby/utils.rb
14 lines 220 B history raw
1require 'benchmark'
3def benchmark(&block)
4 runs = 100
5 total = 0
7 runs.times do |i|
8 result = Benchmark.measure(&block).total
9 $stderr.puts "Run #{i}: #{result}"
10 total += result
11 end
13 total / runs
14end