#!/usr/bin/env ruby $:.unshift File.expand_path('../lib', __dir__) require 'benchmark_driver' require 'optparse' require 'yaml' options = {} args = OptionParser.new do |o| o.banner = "Usage: #{File.basename($0, '.*')} [options] [YAML]" o.on('-d', '--duration [SECONDS]', 'Duration seconds to run each benchmark (default: 1)') do |n| options[:duration] = n.to_i end o.on('-e', '--executables [EXECS]', 'Ruby executables (e1::path1; e2::path2; e3::path3;...)') do |e| options[:execs] ||= [] e.split(/;/).each do |path| options[:execs] << path end end o.on('-r', "--result-format=FORMAT", "Result output format [time|ips] (default: time)", %w[time ips]) do |r| options[:result_format] = r end o.on('-v', '--verbose') do |v| options[:verbose] = v end end.parse!(ARGV) abort "No YAML file is specified" if args.empty? driver = BenchmarkDriver.new(options) args.each do |yaml| benchmarks = YAML.load(File.read(yaml)) if benchmarks.is_a?(Hash) benchmarks[:name] = File.basename(yaml, '.*') end driver.run(benchmarks) end