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

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

Constant Summary collapse

BATCH_SIZE =
1000

Instance Method Summary collapse

Instance Method Details

#full_script(times) ⇒ Object

Raises:

  • (ArgumentError)


180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/benchmark/runner/exec.rb', line 180

def full_script(times)
  raise ArgumentError.new("Negative times: #{times}") if times < 0
  "\#{prelude}\n__benchmark_driver_i = 0\nwhile __benchmark_driver_i < \#{times / BATCH_SIZE}\n  __benchmark_driver_i += 1\n  \#{\"\#{script};\" * BATCH_SIZE}\nend\n\#{\"\#{script};\" * (times % BATCH_SIZE)}\n  RUBY\nend\n"

#overhead_script(times) ⇒ Object

Raises:

  • (ArgumentError)


169
170
171
172
173
174
175
176
177
178
# File 'lib/benchmark/runner/exec.rb', line 169

def overhead_script(times)
  raise ArgumentError.new("Negative times: #{times}") if times < 0
  "\#{prelude}\n__benchmark_driver_i = 0\nwhile __benchmark_driver_i < \#{times / BATCH_SIZE}\n  __benchmark_driver_i += 1\nend\n  RUBY\nend\n"