Sha256: c8b69ca2d9f30a7e9cce8cf63b571111e8ebbf2f8883f0fcdedd8b62b80d94f8

Contents?: true

Size: 1.44 KB

Versions: 21

Compression:

Stored size: 1.44 KB

Contents

class Benchmark::Output::Time
  # This class requires runner to measure following fields in `Benchmark::Driver::BenchmarkResult` to show output.
  REQUIRED_FIELDS = [:real]

  # @param [Array<Benchmark::Driver::Configuration::Job>] jobs
  # @param [Array<Benchmark::Driver::Configuration::Executable>] executables
  # @param [Benchmark::Driver::Configuration::OutputOptions] options
  def initialize(jobs:, executables:, options:)
    @jobs = jobs
    @executables = executables
    @options = options
    @name_length = jobs.map { |j| j.name.size }.max
  end

  def start_warming
    $stdout.print 'warming up...'
  end

  # @param [String] name
  def warming(name)
    # noop
  end

  # @param [Benchmark::Driver::BenchmarkResult] result
  def warmup_stats(result)
    $stdout.print '.'
  end

  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

  # @param [String] name
  def running(name)
    $stdout.print("%-#{@name_length}s  " % name)
    @ran_num = 0
  end

  # @param [Benchmark::Driver::BenchmarkResult] result
  def benchmark_stats(result)
    $stdout.print('%-6.3f  ' % result.real)
    @ran_num += 1
    if @ran_num == @executables.size
      $stdout.puts
    end
  end

  def finish
    # compare is not implemented yet
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
benchmark_driver-0.4.0 lib/benchmark/output/time.rb