lib/benchmark_driver/runner/ips.rb in benchmark_driver-0.13.3 vs lib/benchmark_driver/runner/ips.rb in benchmark_driver-0.14.0
- old
+ new
@@ -99,13 +99,17 @@
loop_count: job.loop_count,
)
duration = Tempfile.open(['benchmark_driver-', '.rb']) do |f|
with_script(benchmark.render(result: f.path)) do |path|
- execute(*context.executable.command, path)
+ IO.popen([*context.executable.command, path], &:read) # TODO: print stdout if verbose=2
+ if $?.success?
+ Float(f.read)
+ else
+ BenchmarkDriver::Result::ERROR
+ end
end
- Float(f.read)
end
value_duration(
loop_count: job.loop_count,
duration: duration,
@@ -117,11 +121,15 @@
METRIC
end
# Overridden by BenchmarkDriver::Runner::Time
def value_duration(duration:, loop_count:)
- [loop_count.to_f / duration, duration]
+ if duration == BenchmarkDriver::Result::ERROR
+ [BenchmarkDriver::Result::ERROR, BenchmarkDriver::Result::ERROR]
+ else
+ [loop_count.to_f / duration, duration]
+ end
end
def with_script(script)
if @config.verbose >= 2
sep = '-' * 30
@@ -134,10 +142,10 @@
return yield(f.path)
end
end
def execute(*args)
- stdout = IO.popen(args, &:read) # handle stdout?
+ stdout = IO.popen(args, &:read) # TODO: print stdout if verbose=2
unless $?.success?
raise "Failed to execute: #{args.shelljoin} (status: #{$?.exitstatus})"
end
end