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
  <<-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)


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
  <<-RUBY
#{prelude}
__benchmark_driver_i = 0
while __benchmark_driver_i < #{times / BATCH_SIZE}
  __benchmark_driver_i += 1
end
  RUBY
end