Class: Bench::Commands::Compare

Inherits:
Command
  • Object
show all
Defined in:
lib/bench9000/commands/compare.rb

Instance Method Summary collapse

Methods inherited from Command

#after, #result

Instance Method Details

#before(options, existing_measurements) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/bench9000/commands/compare.rb', line 14

def before(options, existing_measurements)
  if options.implementations.size < 2
    puts "you need at least two implementations to compare"
    exit
  end
  true
end

#benchmark_complete(options, b, measurements) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bench9000/commands/compare.rb', line 22

def benchmark_complete(options, b, measurements)
  reference = measurements[b, options.implementations[0]]

  if reference == :failed
    reference_info = "(reference failed) "
  else
    reference_info = ""
  end

  puts "#{b} #{reference_info}" + options.implementations.drop(1).map { |i|
    if reference == :failed
      measurements[b, i].score.to_s
    else
      Stats.format_percent(measurements[b, i].score / reference.score)
    end
  }.join(" ")
end