Class: BenchmarkDriver::RubyInterface
- Inherits:
-
Object
- Object
- BenchmarkDriver::RubyInterface
- Defined in:
- lib/benchmark_driver/ruby_interface.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#compare! ⇒ Object
Backward compatibility.
-
#initialize(output: nil, runner: nil) ⇒ RubyInterface
constructor
A new instance of RubyInterface.
- #prelude(script) ⇒ Object
- #report(name, script = nil) ⇒ Object
-
#run ⇒ Object
Build jobs and run.
Constructor Details
#initialize(output: nil, runner: nil) ⇒ RubyInterface
Returns a new instance of RubyInterface.
24 25 26 27 28 29 30 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 24 def initialize(output: nil, runner: nil) @prelude = '' @jobs = [] @config = BenchmarkDriver::Config.new @config.output_type = output.to_s if output @config.runner_type = runner.to_s if runner end |
Class Method Details
.run(**args, &block) ⇒ Object
3 4 5 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 3 def self.run(**args, &block) new(**args).tap { |x| block.call(x) }.run end |
Instance Method Details
#compare! ⇒ Object
Backward compatibility. This is actually default now.
47 48 49 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 47 def compare! @config.output_type = 'compare' end |
#prelude(script) ⇒ Object
33 34 35 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 33 def prelude(script) @prelude << "#{script}\n" end |
#report(name, script = nil) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 39 def report(name, script = nil) if script.nil? script = name end @jobs << { benchmark: [{ name: name, script: script }] } end |
#run ⇒ Object
Build jobs and run. This is NOT interface for users.
8 9 10 11 12 13 14 15 16 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 8 def run jobs = @jobs.flat_map do |job| BenchmarkDriver::JobParser.parse({ type: @config.runner_type, prelude: @prelude, }.merge!(job)) end BenchmarkDriver::Runner.run(jobs, config: @config) end |