lib/benchmark_driver/runner/ips.rb in benchmark_driver-0.13.1 vs lib/benchmark_driver/runner/ips.rb in benchmark_driver-0.13.2
- old
+ new
@@ -194,11 +194,14 @@
def render(result:)
prelude = preludes.reject(&:nil?).reject(&:empty?).join("\n")
<<-RUBY
#{prelude}
-if Process.respond_to?(:clock_gettime) # Ruby 2.1+
+if #{loop_count} == 1
+ __bmdv_empty_before = 0
+ __bmdv_empty_after = 0
+elsif Process.respond_to?(:clock_gettime) # Ruby 2.1+
__bmdv_empty_before = Process.clock_gettime(Process::CLOCK_MONOTONIC)
#{while_loop('', loop_count)}
__bmdv_empty_after = Process.clock_gettime(Process::CLOCK_MONOTONIC)
else
__bmdv_empty_before = Time.now
@@ -228,9 +231,11 @@
private
def while_loop(content, times)
if !times.is_a?(Integer) || times <= 0
raise ArgumentError.new("Unexpected times: #{times.inspect}")
+ elsif times == 1
+ return content
end
# TODO: execute in batch
<<-RUBY
__bmdv_i = 0