Class: BenchmarkDriver::Runner::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark_driver/runner/memory.rb

Overview

Max resident set size

Constant Summary collapse

Job =

JobParser returns this, BenchmarkDriver::Runner.runner_for searches “*::Job”

Class.new(BenchmarkDriver::DefaultJob)
JobParser =

Dynamically fetched and used by BenchmarkDriver::JobParser.parse

BenchmarkDriver::DefaultJobParser.for(Job)
METRICS_TYPE =
BenchmarkDriver::Metrics::Type.new(unit: 'bytes', larger_better: false, worse_word: 'larger')

Instance Method Summary collapse

Constructor Details

#initialize(config:, output:) ⇒ Memory

Returns a new instance of Memory.

Parameters:



19
20
21
22
# File 'lib/benchmark_driver/runner/memory.rb', line 19

def initialize(config:, output:)
  @config = config
  @output = output
end

Instance Method Details

#run(jobs) ⇒ Object

This method is dynamically called by BenchmarkDriver::JobRunner.run

Parameters:

  • jobs (Array<BenchmarkDriver::Default::Job>)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/benchmark_driver/runner/memory.rb', line 26

def run(jobs)
  # Currently Linux's time(1) support only...
  if Etc.uname.fetch(:sysname) != 'Linux'
    raise "memory output is not supported for '#{Etc.uname[:sysname]}' for now"
  end

  @output.metrics_type = METRICS_TYPE

  if jobs.any? { |job| job.loop_count.nil? }
    jobs = jobs.map do |job|
      job.loop_count ? job : Job.new(job.to_h.merge(loop_count: 1))
    end
  end

  @output.with_benchmark do
    jobs.each do |job|
      @output.with_job(job) do
        @config.executables.each do |exec|
          best_metrics = with_repeat(@config.repeat_count) do
            run_benchmark(job, exec: exec)
          end
          @output.report(best_metrics)
        end
      end
    end
  end
end