Class: Benchmark::Runner::Eval::BenchmarkScript

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

Constant Summary collapse

BATCH_SIZE =
1000

Instance Method Summary collapse

Instance Method Details

#full_script(times) ⇒ Object

Raises:

  • (ArgumentError)


134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/benchmark/runner/eval.rb', line 134

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(times) ⇒ Object

Raises:

  • (ArgumentError)


123
124
125
126
127
128
129
130
131
132
# File 'lib/benchmark/runner/eval.rb', line 123

def overhead(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