class Benchmark::Avg::BenchmarkSuite

Public Class Methods

new() click to toggle source
# File lib/benchmark/avg/benchmark_suite.rb, line 12
def initialize
  @options = default_options
  @jobs = []
end

Public Instance Methods

config(options) click to toggle source
# File lib/benchmark/avg/benchmark_suite.rb, line 17
def config(options)
  @options.merge! options
end
report(label = "", &block) click to toggle source
# File lib/benchmark/avg/benchmark_suite.rb, line 21
def report(label = "", &block)
  @jobs << Job.new(label, block)
  self
end
run() click to toggle source
# File lib/benchmark/avg/benchmark_suite.rb, line 26
def run
  puts 'Running your benchmark...'
  divider
  each_job { |job| job.run @options[:warmup], @options[:time] }
  puts 'Benchmarking finished, here are your reports...'
  puts
  puts 'Warm up results:'
  divider
  each_job { |job| puts job.warmup_report }
  puts
  puts 'Runtime results:'
  divider
  each_job { |job| puts job.runtime_report }
  divider
end

Private Instance Methods

default_options() click to toggle source
# File lib/benchmark/avg/benchmark_suite.rb, line 43
def default_options
  {
    warmup: 30,
    time: 60,
  }
end
divider() click to toggle source
# File lib/benchmark/avg/benchmark_suite.rb, line 50
def divider
  puts '-' * OUTPUT_WIDTH
end
each_job(&proc) click to toggle source
# File lib/benchmark/avg/benchmark_suite.rb, line 54
def each_job(&proc)
  @jobs.each &proc
end