class Benchmark::IPS::Job::StdoutReport

Public Class Methods

new() click to toggle source
# File lib/benchmark/ips/job/stdout_report.rb, line 5
def initialize
  @last_item = nil
end

Public Instance Methods

add_report(item, caller) click to toggle source
# File lib/benchmark/ips/job/stdout_report.rb, line 32
def add_report(item, caller)
  $stdout.puts " #{item.body}"
  @last_item = item
end
running(label, _warmup)
Alias for: warming
start_running() click to toggle source
# File lib/benchmark/ips/job/stdout_report.rb, line 13
def start_running
  $stdout.puts "Calculating -------------------------------------"
end
start_warming() click to toggle source
# File lib/benchmark/ips/job/stdout_report.rb, line 9
def start_warming
  $stdout.puts "Warming up --------------------------------------"
end
warming(label, _warmup) click to toggle source
# File lib/benchmark/ips/job/stdout_report.rb, line 17
def warming(label, _warmup)
  $stdout.print rjust(label)
end
Also aliased as: running
warmup_stats(_warmup_time_us, timing) click to toggle source
# File lib/benchmark/ips/job/stdout_report.rb, line 21
def warmup_stats(_warmup_time_us, timing)
  case format
  when :human
    $stdout.printf "%s i/100ms\n", Helpers.scale(timing)
  else
    $stdout.printf "%10d i/100ms\n", timing
  end
end

Private Instance Methods

format() click to toggle source

@return [Symbol] format used for benchmarking

# File lib/benchmark/ips/job/stdout_report.rb, line 46
def format
  Benchmark::IPS.options[:format]
end
rjust(label) click to toggle source

Add padding to label’s right if label’s length < 20, Otherwise add a new line and 20 whitespaces. @return [String] Right justified label.

# File lib/benchmark/ips/job/stdout_report.rb, line 53
def rjust(label)
  label = label.to_s
  if label.size > 20
    "#{label}\n#{' ' * 20}"
  else
    label.rjust(20)
  end
end