Class: Benchmark::Runner::Exec::BenchmarkScript

Inherits:
Struct
  • Object
show all
Defined in:
lib/benchmark/runner/exec.rb

Constant Summary collapse

BATCH_SIZE =
50

Instance Method Summary collapse

Instance Method Details

#full_script(times) ⇒ Object

Raises:

  • (ArgumentError)


177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/benchmark/runner/exec.rb', line 177

def full_script(times)
  raise ArgumentError.new("Negative times: #{times}") if times < 0
  <<-RUBY
#{prelude}
__benchmark_driver_i = 0
while __benchmark_driver_i < #{times / BATCH_SIZE}
  __benchmark_driver_i += 1
  #{"#{script};" * BATCH_SIZE}
end
#{"#{script};" * (times % BATCH_SIZE)}
  RUBY
end

#overhead_script(times) ⇒ Object

Raises:

  • (ArgumentError)


166
167
168
169
170
171
172
173
174
175
# File 'lib/benchmark/runner/exec.rb', line 166

def overhead_script(times)
  raise ArgumentError.new("Negative times: #{times}") if times < 0
  <<-RUBY
#{prelude}
__benchmark_driver_i = 0
while __benchmark_driver_i < #{times / BATCH_SIZE}
  __benchmark_driver_i += 1
end
  RUBY
end