lib/benchmark_driver/output/all.rb in benchmark_driver-0.14.22 vs lib/benchmark_driver/output/all.rb in benchmark_driver-0.15.0

- old
+ new

@@ -1,17 +1,22 @@ class BenchmarkDriver::Output::All NAME_LENGTH = 20 CONTEXT_LENGTH = 20 + OPTIONS = { + sort: ['--output-sort true|false', TrueClass, 'Sort all output or not (default: true)'], + } + # @param [Array<BenchmarkDriver::Metric>] metrics # @param [Array<BenchmarkDriver::Job>] jobs # @param [Array<BenchmarkDriver::Context>] contexts - def initialize(metrics:, jobs:, contexts:) + def initialize(metrics:, jobs:, contexts:, options:) @metrics = metrics @job_names = jobs.map(&:name) @context_names = contexts.map(&:name) @name_length = [@job_names.map(&:length).max, NAME_LENGTH].max + @sort = options.fetch(:sort, true) end def with_warmup(&block) without_stdout_buffering do $stdout.puts 'Warming up --------------------------------------' @@ -65,10 +70,13 @@ if @context_values.empty? print("\r") else print("\e[#{num_values}F") end - @context_values[@context] = result.all_values.values.first.sort + @context_values[@context] = result.all_values.values.first + if @sort + @context_values[@context] = @context_values[@context].sort + end precision = result.values.values.first.to_s.sub(/\A\d+\./, '').length num_values.times do |i| if i == 0 $stdout.print(@job_name)