Class: Benchmark::Output::Ips
- Inherits:
-
Object
- Object
- Benchmark::Output::Ips
- Defined in:
- lib/benchmark/output/ips.rb
Constant Summary collapse
- REQUIRED_FIELDS =
This class requires runner to measure following fields in ‘Benchmark::Driver::BenchmarkResult` to show output.
[:real]
- NAME_LENGTH =
20
Instance Method Summary collapse
- #benchmark_stats(result) ⇒ Object
- #finish ⇒ Object
-
#initialize(jobs:, executables:, options:) ⇒ Ips
constructor
A new instance of Ips.
- #running(name) ⇒ Object
- #start_running ⇒ Object
- #start_warming ⇒ Object
- #warming(name) ⇒ Object
- #warmup_stats(result) ⇒ Object
Constructor Details
#initialize(jobs:, executables:, options:) ⇒ Ips
10 11 12 13 14 15 16 |
# File 'lib/benchmark/output/ips.rb', line 10 def initialize(jobs:, executables:, options:) @jobs = jobs @executables = executables = @results = [] @name_by_result = {} end |
Instance Method Details
#benchmark_stats(result) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/benchmark/output/ips.rb', line 53 def benchmark_stats(result) executable = @executables[@row_results.size] $stdout.print("#{humanize(result.ips, [10, executable.name.length].max)} ") @results << result @row_results << result if @row_results.size == @executables.size $stdout.print("i/s - #{humanize(result.iterations)} in") @row_results.each do |r| $stdout.print(" %3.6fs" % r.real) end $stdout.puts end @name_by_result[result] = executable.name end |
#finish ⇒ Object
70 71 72 73 74 |
# File 'lib/benchmark/output/ips.rb', line 70 def finish if @results.size > 1 && .compare compare end end |
#running(name) ⇒ Object
47 48 49 50 |
# File 'lib/benchmark/output/ips.rb', line 47 def running(name) warming(name) @row_results = [] end |
#start_running ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/benchmark/output/ips.rb', line 36 def start_running $stdout.puts 'Calculating -------------------------------------' if @executables.size > 1 $stdout.print(' ' * NAME_LENGTH) @executables.each do |executable| $stdout.print(" %10s " % executable.name) end $stdout.puts end end |
#start_warming ⇒ Object
18 19 20 |
# File 'lib/benchmark/output/ips.rb', line 18 def start_warming $stdout.puts 'Warming up --------------------------------------' end |
#warming(name) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/benchmark/output/ips.rb', line 23 def warming(name) if name.length > NAME_LENGTH $stdout.puts(name) else $stdout.print("%#{NAME_LENGTH}s" % name) end end |
#warmup_stats(result) ⇒ Object
32 33 34 |
# File 'lib/benchmark/output/ips.rb', line 32 def warmup_stats(result) $stdout.puts "#{humanize(result.ip100ms)} i/100ms" end |