Class: Bench::Commands::CompareReference
- Defined in:
- lib/bench9000/commands/compare-reference.rb
Instance Method Summary collapse
- #before(options, existing_measurements) ⇒ Object
- #benchmark_complete(options, b, measurements) ⇒ Object
- #read_reference_scores ⇒ Object
Methods inherited from Command
Instance Method Details
#before(options, existing_measurements) ⇒ Object
14 15 16 17 |
# File 'lib/bench9000/commands/compare-reference.rb', line 14 def before(, existing_measurements) @reference_scores = read_reference_scores true end |
#benchmark_complete(options, b, measurements) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bench9000/commands/compare-reference.rb', line 19 def benchmark_complete(, b, measurements) reference_score = @reference_scores[b.name] if reference_score.nil? puts "reference for #{b} missing" return end puts "#{b} " + .implementations.map { |i| if reference_score == :failed if measurements[b, i] == :failed "reference and new failed" else "reference failed: new score: #{measurements[b, i].score}" end elsif measurements[b, i] == :failed "new failed: reference score: #{reference_score}" else Stats.format_percent(measurements[b, i].score / reference_score) end }.join(" ") end |
#read_reference_scores ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/bench9000/commands/compare-reference.rb', line 42 def read_reference_scores reference_scores = {} reference_file = File.open("reference.txt", "r") if reference_file.gets.strip != "version #{CONFIG_VERSION}" puts "the benchmarks have changed since this file was created" exit 1 end reference_file.each do |line| benchmark, score = line.split if score == "failed" score = :failed else score = score.to_i end reference_scores[benchmark] = score end reference_scores end |