Class: Benchmark::Avg::BenchmarkSuite

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark/avg/benchmark_suite.rb

Instance Method Summary collapse

Constructor Details

#initializeBenchmarkSuite



12
13
14
15
# File 'lib/benchmark/avg/benchmark_suite.rb', line 12

def initialize
  @options = default_options
  @jobs = []
end

Instance Method Details

#config(options) ⇒ Object



17
18
19
# File 'lib/benchmark/avg/benchmark_suite.rb', line 17

def config(options)
  @options.merge! options
end

#report(label = "", &block) ⇒ Object



21
22
23
24
# File 'lib/benchmark/avg/benchmark_suite.rb', line 21

def report(label = "", &block)
  @jobs << Job.new(label, block)
  self
end

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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