Sha256: 9238a9c203e18b680bdc050a1ae3731b1372f2cf99a411f653bee37d20887123

Contents?: true

Size: 1.85 KB

Versions: 17

Compression:

Stored size: 1.85 KB

Contents

require 'benchmark_driver/struct'
require 'benchmark_driver/metrics'
require 'tempfile'
require 'shellwords'

# Run only once, for testing
class BenchmarkDriver::Runner::Recorded
  # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
  Job = ::BenchmarkDriver::Struct.new(
    :name,              # @param [String] name - This is mandatory for all runner
    :job,               # @param [BenchmarkDriver::Runner::*::Job]
    :warmup_metrics,    # @param [Hash]
    :benchmark_metrics, # @param [Hash]
    :metrics_type,      # @param [BenchmarkDriver::Metrics::Type]
  )
  # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
  class << JobParser = Module.new
    # @param [Hash] metrics_by_job
    # @param [BenchmarkDriver::Metrics::Type] metrics_type
    def parse(metrics_by_job:, metrics_type:)
      metrics_by_job.map do |job, metrics_hash|
        Job.new(
          name: job.name,
          job: job,
          warmup_metrics: metrics_hash.fetch(:warmup, []),
          benchmark_metrics: metrics_hash.fetch(:benchmark),
          metrics_type: metrics_type,
        )
      end
    end
  end

  # @param [BenchmarkDriver::Config::RunnerConfig] config
  # @param [BenchmarkDriver::Output::*] output
  def initialize(config:, output:)
    @config = config
    @output = output
  end

  # This method is dynamically called by `BenchmarkDriver::JobRunner.run`
  # @param [Array<BenchmarkDriver::Default::Job>] jobs
  def run(records)
    @output.metrics_type = records.first.metrics_type

    records.each do |record|
      unless record.warmup_metrics.empty?
        # TODO:
      end
    end

    @output.with_benchmark do
      records.each do |record|
        @output.with_job(record.job) do
          record.benchmark_metrics.each do |metrics|
            @output.report(metrics)
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
benchmark_driver-0.10.16 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.15 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.14 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.13 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.12 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.11 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.10 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.9 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.8 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.7 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.6 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.5 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.4 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.3 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.2 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.1 lib/benchmark_driver/runner/recorded.rb
benchmark_driver-0.10.0 lib/benchmark_driver/runner/recorded.rb