class BenchmarkDriver::RubyInterface
Public Class Methods
new(output: nil, runner: nil, repeat_count: 1)
click to toggle source
@param [String,NilClass] output @param [String,NilClass] runner
# 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
run(**args, &block)
click to toggle source
# File lib/benchmark_driver/ruby_interface.rb, line 3 def self.run(**args, &block) new(**args).tap { |x| block.call(x) }.run end
Public Instance Methods
compare!()
click to toggle source
Backward compatibility. This is actually default now.
# File lib/benchmark_driver/ruby_interface.rb, line 64 def compare! @config.output_type = 'compare' end
executable(name:, command:)
click to toggle source
# File lib/benchmark_driver/ruby_interface.rb, line 87 def executable(name:, command:) raise ArgumentError, "`command' should be an Array" unless command.kind_of? Array @executables << BenchmarkDriver::Config::Executable.new(name: name, command: command) end
loop_count(count)
click to toggle source
@param [Integer] count
# File lib/benchmark_driver/ruby_interface.rb, line 46 def loop_count(count) @loop_count = count end
output(type)
click to toggle source
# File lib/benchmark_driver/ruby_interface.rb, line 59 def output(type) @config.output_type = type end
prelude(script)
click to toggle source
@param [String] script
# File lib/benchmark_driver/ruby_interface.rb, line 41 def prelude(script) @prelude << "#{script}\n" end
rbenv(*versions)
click to toggle source
# 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)
click to toggle source
@param [String] name - Name shown on result output. @param [String,nil] script - Benchmarked script in String. If nil, name is considered as script too.
# 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
ridkuse(*versions)
click to toggle source
ridk use command for RubyInstaller2 on Windows
# File lib/benchmark_driver/ruby_interface.rb, line 81 def ridkuse(*versions) versions.each do |version| @executables << BenchmarkDriver::RidkUse.parse_spec(version) end end
run()
click to toggle source
Build jobs and run. This is NOT interface for users.
# 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
rvm(*versions)
click to toggle source
# File lib/benchmark_driver/ruby_interface.rb, line 74 def rvm(*versions) versions.each do |version| @executables << BenchmarkDriver::Rvm.parse_spec(version) end end
verbose(level = 1)
click to toggle source
# File lib/benchmark_driver/ruby_interface.rb, line 92 def verbose(level = 1) @config.verbose = level end