module SimpleBench
Implementation of SimpleBench
gem
Public Class Methods
n_times(*methods, number_of_times)
click to toggle source
Expects Strings. Runs each method once, and then as many times as specified
# File lib/simple_bench.rb, line 16 def n_times(*methods, number_of_times) Benchmark.bmbm do |x| methods.each do |method| x.report("#{method}_once") { send(method) } end run_multiple_times(x, number_of_times, methods) end end
simple(*methods)
click to toggle source
Expects Strings. Runs each method once.
# File lib/simple_bench.rb, line 7 def simple(*methods) Benchmark.bmbm do |x| methods.each do |method| x.report("#{method}_once") { send(method) } end end end
tiered(*methods)
click to toggle source
Expects Strings. Runs each method once, and then 1_000 times, 20_000 times, and 75_000 times
# File lib/simple_bench.rb, line 28 def tiered(*methods) Benchmark.bmbm do |x| tiers = [1_000, 20_000, 75_000] methods.each do |method| x.report("#{method}_once") { send(method) } end tiers.each do |tier| run_multiple_times(x, tier, methods) end end end
Private Class Methods
run_multiple_times(x, number_of_times, methods)
click to toggle source
# File lib/simple_bench.rb, line 44 def run_multiple_times(x, number_of_times, methods) methods.each do |method| x.report("#{method}_#{number_of_times}_times") do number_of_times.times { send(method) } end end end