Sha256: e04af51c834f0c4113d072de0eb5e9a4c7f810390664e4c07aa7fba3088ab71e

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

require 'benchmark_driver/default_job'
require 'benchmark_driver/default_job_parser'

class BenchmarkDriver::Runner::Block < BenchmarkDriver::Runner::Ips
  METRIC = BenchmarkDriver::Metric.new(name: 'Iteration per second', unit: 'i/s')

  # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
  Job = Class.new(BenchmarkDriver::DefaultJob)

  # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
  JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC]).extend(Module.new{
    def parse(*)
      jobs = super
      jobs.map do |job|
        job = job.dup
        job.prelude = "#{job.prelude}\n__bmdv_script_block = proc { #{job.script} }"
        job.script = '__bmdv_script_block.call'
        job
      end
    end
  })
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
benchmark_driver-0.14.21 lib/benchmark_driver/runner/block.rb
benchmark_driver-0.14.20 lib/benchmark_driver/runner/block.rb