Sha256: b82ba836b0f49a920f4acd6003663e64c31561b9e933aed56cf365b489fcf882

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

require 'benchmark_driver/struct'

module BenchmarkDriver
  # All CLI options
  Config = ::BenchmarkDriver::Struct.new(
    :runner_type,   # @param [String]
    :output_type,   # @param [String]
    :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]
    :verbose,       # @param [Integer]
    defaults: {
      runner_type: 'ips',
      output_type: 'compare',
      filters: [],
      repeat_count: 1,
      repeat_result: 'best',
      run_duration: 3.0,
      verbose: 0,
    },
  )

  # Subset of FullConfig passed to JobRunner
  Config::RunnerConfig = ::BenchmarkDriver::Struct.new(
    :repeat_count,  # @param [Integer]
    :repeat_result, # @param [String]
    :run_duration,  # @param [Float]
    :verbose,       # @param [Integer]
  )

  Config::Executable = ::BenchmarkDriver::Struct.new(
    :name,    # @param [String]
    :command, # @param [Array<String>]
  ) do
    def initialize(*)
      super
      @cache = {} # modifiable storage even after `#freeze`
    end

    # @return [String] - Return result of `ruby -v`. This is for convenience of output plugins.
    def description
      @cache[:description] ||= IO.popen([*command, '-v'], &:read).rstrip
    end

    # @return [String] - Return RUBY_VERSION
    def version
      @cache[:version] ||= IO.popen([*command, '-e', 'print RUBY_VERSION'], &:read)
    end
  end
  Config.defaults[:executables] = [
    BenchmarkDriver::Config::Executable.new(name: RUBY_VERSION, command: [RbConfig.ruby]),
  ]
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
benchmark_driver-0.14.5 lib/benchmark_driver/config.rb
benchmark_driver-0.14.4 lib/benchmark_driver/config.rb
benchmark_driver-0.14.3 lib/benchmark_driver/config.rb
benchmark_driver-0.14.2 lib/benchmark_driver/config.rb
benchmark_driver-0.14.0 lib/benchmark_driver/config.rb
benchmark_driver-0.13.3 lib/benchmark_driver/config.rb
benchmark_driver-0.13.2 lib/benchmark_driver/config.rb
benchmark_driver-0.13.1 lib/benchmark_driver/config.rb
benchmark_driver-0.13.0 lib/benchmark_driver/config.rb