lib/benchmark_driver/output/compare.rb in benchmark_driver-0.14.20 vs lib/benchmark_driver/output/compare.rb in benchmark_driver-0.14.21
- old
+ new
@@ -179,10 +179,21 @@
end
show_results(results, show_context: true)
end
end
+ def show_slower(better_result, worse_result)
+ top = worse_result.value
+ bottom = better_result.value
+ top, bottom = bottom, top if @metrics.first.larger_better
+
+ unless BenchmarkDriver::Result::ERROR.equal?(bottom)
+ ratio = top / bottom
+ "- %.2fx #{@metrics.first.worse_word}" % ratio
+ end
+ end
+
# @param [Array<BenchmarkDriver::Output::Compare::Result>] results
# @param [TrueClass,FalseClass] show_context
def show_results(results, show_context:)
results = results.sort_by do |result|
if @metrics.first.larger_better
@@ -192,17 +203,10 @@
end
end
first = results.first
results.each do |result|
- if result != first
- if @metrics.first.larger_better
- ratio = (first.value / result.value)
- else
- ratio = (result.value / first.value)
- end
- slower = "- %.2fx #{@metrics.first.worse_word}" % ratio
- end
+ slower = show_slower(first, result) if result != first
if show_context
name = result.context.name
else
name = result.job
end