class Bench::Commands::CompareReference
Public Instance Methods
before(options, existing_measurements)
click to toggle source
# File lib/bench9000/commands/compare-reference.rb, line 14 def before(options, existing_measurements) @reference_scores = read_reference_scores true end
benchmark_complete(options, b, measurements)
click to toggle source
# File lib/bench9000/commands/compare-reference.rb, line 19 def benchmark_complete(options, b, measurements) reference_score = @reference_scores[b.name] if reference_score.nil? puts "reference for #{b} missing" return end puts "#{b} " + options.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()
click to toggle source
# 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