Class: BenchmarkRunner
- Inherits:
-
Object
show all
- Defined in:
- lib/tasks/benchmark_runner.rb
Defined Under Namespace
Classes: BenchItem, BenchRoot
Instance Method Summary
collapse
Constructor Details
#initialize(run_time: nil, items: nil, format: nil, adapter: nil, direction: nil) ⇒ BenchmarkRunner
Returns a new instance of BenchmarkRunner.
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/tasks/benchmark_runner.rb', line 13
def initialize(run_time: nil, items: nil, format: nil, adapter: nil,
direction: nil)
@run_time = run_time || 5
@items = items || 10
@format = format
@adapter = adapter
@direction = direction
@label = self.class.name.split("::")[1]
set_adapter
end
|
Instance Method Details
25
26
27
28
29
|
# File 'lib/tasks/benchmark_runner.rb', line 25
def from_format
input = generate_data
time_runs { BenchRoot.send("from_#{@format}", input) }
end
|
#run_benchmarks ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/tasks/benchmark_runner.rb', line 37
def run_benchmarks
if @direction == :from
from_format
elsif @direction == :to
to_format
end
end
|
31
32
33
34
35
|
# File 'lib/tasks/benchmark_runner.rb', line 31
def to_format
model = generate_model
time_runs { model.send("to_#{@format}") }
end
|