lib/benchmark_driver/runner/ips.rb in benchmark_driver-0.13.0 vs lib/benchmark_driver/runner/ips.rb in benchmark_driver-0.13.1
- old
+ new
@@ -68,11 +68,11 @@
# @param [BenchmarkDriver::Runner::Ips::Job] job - loop_count is nil
# @param [BenchmarkDriver::Context] context
def run_warmup(job, context:)
warmup = WarmupScript.new(
- prelude: "#{context.prelude}\n#{job.prelude}",
+ preludes: [context.prelude, job.prelude],
script: job.script,
teardown: job.teardown,
loop_count: job.loop_count,
first_warmup_duration: @config.run_duration / 6.0, # default: 0.5
second_warmup_duration: @config.run_duration / 3.0, # default: 1.0
@@ -91,11 +91,11 @@
# @param [BenchmarkDriver::Runner::Ips::Job] job - loop_count is not nil
# @param [BenchmarkDriver::Context] context
# @return [BenchmarkDriver::Metrics]
def run_benchmark(job, context:)
benchmark = BenchmarkScript.new(
- prelude: "#{context.prelude}\n#{job.prelude}",
+ preludes: [context.prelude, job.prelude],
script: job.script,
teardown: job.teardown,
loop_count: job.loop_count,
)
@@ -134,19 +134,20 @@
return yield(f.path)
end
end
def execute(*args)
- IO.popen(args, &:read) # handle stdout?
+ stdout = IO.popen(args, &:read) # handle stdout?
unless $?.success?
raise "Failed to execute: #{args.shelljoin} (status: #{$?.exitstatus})"
end
end
- WarmupScript = ::BenchmarkDriver::Struct.new(:prelude, :script, :teardown, :loop_count, :first_warmup_duration, :second_warmup_duration) do
+ WarmupScript = ::BenchmarkDriver::Struct.new(:preludes, :script, :teardown, :loop_count, :first_warmup_duration, :second_warmup_duration) do
# @param [String] result - A file to write result
def render(result:)
+ prelude = preludes.reject(&:nil?).reject(&:empty?).join("\n")
<<-RUBY
#{prelude}
# first warmup
__bmdv_i = 0
@@ -186,12 +187,13 @@
# @param [String] prelude
# @param [String] script
# @param [String] teardown
# @param [Integer] loop_count
- BenchmarkScript = ::BenchmarkDriver::Struct.new(:prelude, :script, :teardown, :loop_count) do
+ BenchmarkScript = ::BenchmarkDriver::Struct.new(:preludes, :script, :teardown, :loop_count) do
# @param [String] result - A file to write result
def render(result:)
+ prelude = preludes.reject(&:nil?).reject(&:empty?).join("\n")
<<-RUBY
#{prelude}
if Process.respond_to?(:clock_gettime) # Ruby 2.1+
__bmdv_empty_before = Process.clock_gettime(Process::CLOCK_MONOTONIC)