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, repeat_count: 1) ⇒ RubyInterface
constructor
A new instance of RubyInterface.
- #loop_count(count) ⇒ Object
- #output(type) ⇒ Object
- #prelude(script) ⇒ Object
- #rbenv(*versions) ⇒ Object
- #report(name, script = nil) ⇒ Object
-
#run ⇒ Object
Build jobs and run.
- #verbose(level = 1) ⇒ Object
Constructor Details
#initialize(output: nil, runner: nil, repeat_count: 1) ⇒ RubyInterface
Returns a new instance of RubyInterface.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 29 def initialize(output: nil, runner: nil, repeat_count: 1) @prelude = '' @loop_count = nil @jobs = [] @config = BenchmarkDriver::Config.new @config.output_type = output.to_s if output @config.runner_type = runner.to_s if runner @config.repeat_count = Integer(repeat_count) @executables = [] 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.
64 65 66 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 64 def compare! @config.output_type = 'compare' end |
#loop_count(count) ⇒ Object
46 47 48 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 46 def loop_count(count) @loop_count = count end |
#output(type) ⇒ Object
59 60 61 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 59 def output(type) @config.output_type = type end |
#prelude(script) ⇒ Object
41 42 43 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 41 def prelude(script) @prelude << "#{script}\n" end |
#rbenv(*versions) ⇒ Object
68 69 70 71 72 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 68 def rbenv(*versions) versions.each do |version| @executables << BenchmarkDriver::Rbenv.parse_spec(version) end end |
#report(name, script = nil) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 52 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 17 18 19 20 21 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 8 def run unless @executables.empty? @config.executables = @executables end jobs = @jobs.flat_map do |job| BenchmarkDriver::JobParser.parse({ type: @config.runner_type, prelude: @prelude, loop_count: @loop_count, }.merge!(job)) end BenchmarkDriver::Runner.run(jobs, config: @config) end |
#verbose(level = 1) ⇒ Object
74 75 76 |
# File 'lib/benchmark_driver/ruby_interface.rb', line 74 def verbose(level = 1) @config.verbose = level end |