Module: BenchmarkDriver

Defined in:
lib/benchmark_driver/metric.rb,
lib/benchmark_driver/rvm.rb,
lib/benchmark_driver/rbenv.rb,
lib/benchmark_driver/config.rb,
lib/benchmark_driver/output.rb,
lib/benchmark_driver/runner.rb,
lib/benchmark_driver/struct.rb,
lib/benchmark_driver/ridkuse.rb,
lib/benchmark_driver/version.rb,
lib/benchmark_driver/repeater.rb,
lib/benchmark_driver/job_parser.rb,
lib/benchmark_driver/bulk_output.rb,
lib/benchmark_driver/default_job.rb,
lib/benchmark_driver/ruby_interface.rb,
lib/benchmark_driver/default_job_parser.rb

Overview

Extended Struct with:

* Polyfilled `keyword_init: true`
* Default value configuration
* Deeply freezing members

Defined Under Namespace

Modules: DefaultJobParser, Metrics, Rbenv, Repeater, RidkUse, Runner, Rvm Classes: BulkOutput, JobParser=Module.new, Output, RubyInterface, Struct=Module.new

Constant Summary collapse

Config =

All CLI options

::BenchmarkDriver::Struct.new(
  :runner_type,   # @param [String]
  :output_type,   # @param [String]
  :output_opts,   # @param [Hash{ Symbol => Object }]
  :paths,         # @param [Array<String>]
  :executables,   # @param [Array<BenchmarkDriver::Config::Executable>]
  :filters,       # @param [Array<Regexp>]
  :repeat_count,  # @param [Integer]
  :repeat_result, # @param [String]
  :run_duration,  # @param [Float]
  :timeout,       # @param [Float,nil]
  :verbose,       # @param [Integer]
  defaults: {
    runner_type: 'ips',
    output_type: 'compare',
    output_opts: {},
    filters: [],
    repeat_count: 1,
    repeat_result: 'best',
    run_duration: 3.0,
    verbose: 0,
  },
)
Job =

Holding identifier of measured workload

::BenchmarkDriver::Struct.new(
  :name, # @param [String] - Name of the benchmark task
)
Context =

Benchmark conditions that can be known before running benchmark

::BenchmarkDriver::Struct.new(
  :name,        # @param [String] - Name of the context
  :executable,  # @param [BenchmarkDriver::Config::Executable] - Measured Ruby executable
  :gems,        # @param [Hash{ String => String,nil }] - Gem -> version pairs used for the benchmark
  :prelude,     # @param [String,nil] - Context specific setup script (optional)
  defaults: { prelude: '', gems: {} },
)
Result =

Everything that can be known after running benchmark

::BenchmarkDriver::Struct.new(
  :values,      # @param [Hash{ BenchmarkDriver::Metric => Float }] - Main benchmark results
  :all_values,  # @param [Hash{ BenchmarkDriver::Metric => Float }] - All benchmark results. Used by --output=all (optional)
  :duration,    # @param [Float,nil] - Time taken to run the benchmark job (optional)
  :loop_count,  # @param [Integer,nil] - Times to run the benchmark job (optional)
  :environment, # @param [Hash] - Any other key -> value pairs to express the benchmark context
  defaults: { environment: {} },
)
Metric =

A kind of thing to be measured

::BenchmarkDriver::Struct.new(
  :name,          # @param [String] - Metric name or description like "Max Resident Set Size"
  :unit,          # @param [String] - A unit like "MiB"
  :larger_better, # @param [TrueClass,FalseClass] - If true, larger value is preferred when measured multiple times.
  :worse_word,    # @param [String] - A label shown when the value is worse.
  defaults: { larger_better: true, worse_word: 'slower' },
)
VERSION =
'0.15.15'
DefaultJob =
::BenchmarkDriver::Struct.new(
  :name,       # @param [String] name - This is mandatory for all runner
  :metrics,    # @param [Array<BenchmarkDriver::Metric>] - This is mandatory for all runner too, set by job parser.
  :contexts,   # @param [Array<BenchmarkDriver::Context>] - This is optional parameter for runners.
  :script,     # @param [String] benchmark
  :prelude,    # @param [String,nil] prelude (optional)
  :teardown,   # @param [String,nil] after (optional)
  :loop_count, # @param [Integer,nil] loop_count (optional)
  :required_ruby_version, # @param [String,nil] required_ruby_version (optional)
  defaults: { prelude: '', teardown: '' },
) do
  def runnable_contexts(contexts)
    if required_ruby_version
      contexts.select do |context|
        Gem::Version.new(context.executable.version) >= Gem::Version.new(required_ruby_version)
      end.tap do |result|
        if result.empty?
          raise "No Ruby executables conforming required_ruby_version (#{required_ruby_version}) are specified"
        end
      end
    else
      contexts
    end
  end
end