module BenchmarkDriver::Runner::RubyStdout::JobParser
Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
Public Class Methods
parse(name:, command:, working_directory: nil, metrics:, environment: {})
click to toggle source
@param [String] name @param [String] command @param [String,NilClass] working_directory @param [Hash] metrics_type @param [String] stdout_to_metrics
# File lib/benchmark_driver/runner/ruby_stdout.rb, line 25 def parse(name:, command:, working_directory: nil, metrics:, environment: {}) unless metrics.is_a?(Hash) raise ArgumentError.new("metrics must be Hash, but got #{metrics.class}") end if metrics.size == 0 raise ArgumentError.new('At least one metric must be specified"') elsif metrics.size != 1 raise NotImplementedError.new('Having multiple metrics is not supported yet') end metric, value_from_stdout = parse_metric(*metrics.first) environment_from_stdout = Hash[environment.map { |k, v| [k, parse_environment(v)] }] Job.new( name: name, command: command.shellsplit, working_directory: working_directory, metrics: [metric], value_from_stdout: value_from_stdout, environment_from_stdout: environment_from_stdout, ) end
Private Class Methods
parse_environment(from_stdout:)
click to toggle source
# File lib/benchmark_driver/runner/ruby_stdout.rb, line 60 def parse_environment(from_stdout:) from_stdout end
parse_metric(name, unit:, from_stdout:, larger_better: true, worse_word: 'slower')
click to toggle source
# File lib/benchmark_driver/runner/ruby_stdout.rb, line 50 def parse_metric(name, unit:, from_stdout:, larger_better: true, worse_word: 'slower') metric = BenchmarkDriver::Metric.new( name: name, unit: unit, larger_better: larger_better, worse_word: worse_word, ) [metric, from_stdout] end