Class: Benchmark::Output::Time
- Inherits:
-
Object
- Object
- Benchmark::Output::Time
- Defined in:
- lib/benchmark/output/time.rb
Constant Summary collapse
- REQUIRED_FIELDS =
This class requires runner to measure following fields in ‘Benchmark::Driver::BenchmarkResult` to show output.
[:real]
Instance Method Summary collapse
- #benchmark_stats(result) ⇒ Object
- #finish ⇒ Object
-
#initialize(jobs:, executables:, options:) ⇒ Time
constructor
A new instance of Time.
- #running(name) ⇒ Object
- #start_running ⇒ Object
- #start_warming ⇒ Object
- #warming(name) ⇒ Object
- #warmup_stats(result) ⇒ Object
Constructor Details
#initialize(jobs:, executables:, options:) ⇒ Time
Returns a new instance of Time.
8 9 10 11 12 13 |
# File 'lib/benchmark/output/time.rb', line 8 def initialize(jobs:, executables:, options:) @jobs = jobs @executables = executables @options = @name_length = jobs.map { |j| j.name.size }.max end |
Instance Method Details
#benchmark_stats(result) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/benchmark/output/time.rb', line 46 def benchmark_stats(result) $stdout.print('%-6.3f ' % result.real) @ran_num += 1 if @ran_num == @executables.size $stdout.puts end end |
#finish ⇒ Object
54 55 56 |
# File 'lib/benchmark/output/time.rb', line 54 def finish # compare is not implemented yet end |
#running(name) ⇒ Object
40 41 42 43 |
# File 'lib/benchmark/output/time.rb', line 40 def running(name) $stdout.print("%-#{@name_length}s " % name) @ran_num = 0 end |
#start_running ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/benchmark/output/time.rb', line 29 def start_running $stdout.puts if @jobs.any?(&:warmup_needed?) $stdout.puts 'benchmark results (s):' $stdout.print("%-#{@name_length}s " % 'ruby') @executables.each do |executable| $stdout.print('%-6s ' % executable.name) end $stdout.puts end |
#start_warming ⇒ Object
15 16 17 |
# File 'lib/benchmark/output/time.rb', line 15 def start_warming $stdout.print 'warming up...' end |
#warming(name) ⇒ Object
20 21 22 |
# File 'lib/benchmark/output/time.rb', line 20 def warming(name) # noop end |
#warmup_stats(result) ⇒ Object
25 26 27 |
# File 'lib/benchmark/output/time.rb', line 25 def warmup_stats(result) $stdout.print '.' end |