Class: Bench::Commands::Reference

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

Instance Method Summary collapse

Methods inherited from Command

#benchmark_complete

Instance Method Details

#after(options, measurements) ⇒ Object



39
40
41
# File 'lib/bench9000/commands/reference.rb', line 39

def after(options, measurements)
  @file.close
end

#before(options, existing_measurements) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bench9000/commands/reference.rb', line 14

def before(options, existing_measurements)
  if options.implementations.size != 1
    puts "needs exactly one implementation"
    exit 1
  end

  @file = File.open("reference.txt", "w")
  @file.puts "version #{CONFIG_VERSION}"
  @file.flush

  true
end

#result(options, b, i, measurement) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bench9000/commands/reference.rb', line 27

def result(options, b, i, measurement)
  if measurement == :failed
    score = "failed"
  else
    score = measurement.score
  end

  puts "#{b.name} #{score}"
  @file.puts "#{b.name} #{score}"
  @file.flush
end