ruby-changes:51694
From: k0kubun <ko1@a...>
Date: Mon, 9 Jul 2018 03:33:48 +0900 (JST)
Subject: [ruby-changes:51694] k0kubun:r63906 (trunk): benchmark/driver.rb: make this more similar
k0kubun 2018-07-09 03:33:43 +0900 (Mon, 09 Jul 2018) New Revision: 63906 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63906 Log: benchmark/driver.rb: make this more similar to original benchmark-driver command. I'm going to add some runner plugins to resurrect metrics which were originally supported by benchmark/driver.rb... Modified files: trunk/benchmark/driver.rb Index: benchmark/driver.rb =================================================================== --- benchmark/driver.rb (revision 63905) +++ benchmark/driver.rb (revision 63906) @@ -39,13 +39,27 @@ end https://github.com/ruby/ruby/blob/trunk/benchmark/driver.rb#L39 if __FILE__ == $0 opt = { + runner: 'ips', + output: 'compare', execs: [], - dir: File.dirname(__FILE__), + rbenvs: [], repeat: 1, verbose: 1, + dir: File.dirname(__FILE__), } parser = OptionParser.new{|o| + # + # Original benchmark-driver imitation + # + o.on('-r', '--runner [TYPE]', 'Specify runner type: ips, time, memory, once (default: ips)'){|r| + abort '-r, --runner must take argument but not given' if r.nil? + opt[:runner] = r + } + o.on('-o', '--output [TYPE]', 'Specify output type: compare, simple, markdown, record (default: compare)'){|o| + abort '-o, --output must take argument but not given' if o.nil? + opt[:output] = o + } o.on('-e', '--executables [EXECS]', "Specify benchmark one or more targets (e1::path1; e2::path2; e3::path3;...)"){|e| e.split(/;/).each{|path| @@ -53,33 +67,39 @@ if __FILE__ == $0 https://github.com/ruby/ruby/blob/trunk/benchmark/driver.rb#L67 } } o.on('--rbenv [VERSIONS]', 'Specify benchmark targets with rbenv version (vX.X.X;vX.X.X;...)'){|v| - v.split(/;/).each{|version| - opt[:execs] << "#{version}::#{`RBENV_VERSION='#{version}' rbenv which ruby`.rstrip}" - } + opt[:rbenvs] << v + } + o.on('--repeat-count [NUM]', "Repeat count"){|n| + opt[:repeat] = n.to_i + } + o.on('--verbose [LEVEL]', 'Show some verbose outputs: 0, 1, 2 (default: 1)'){|v| + opt[:verbose] = Integer(v) } - o.on('-d', '--directory [DIRECTORY]', "Benchmark suites directory"){|d| + + # + # benchmark/driver.rb original (deprecated, to be removed later) + # + o.on('--directory [DIRECTORY]', "Benchmark suites directory"){|d| opt[:dir] = d } - o.on('-p', '--pattern [PATTERN]', "Benchmark name pattern"){|p| + o.on('--pattern [PATTERN]', "Benchmark name pattern"){|p| opt[:pattern] = p } - o.on('-x', '--exclude [PATTERN]', "Benchmark exclude pattern"){|e| + o.on('--exclude [PATTERN]', "Benchmark exclude pattern"){|e| opt[:exclude] = e } - o.on('-r', '--repeat-count [NUM]', "Repeat count"){|n| - opt[:repeat] = n.to_i - } - o.on('-v', '--verbose'){|v| - opt[:verbose] = 2 - } - o.on('-q', '--quiet', "Run without notify information except result table."){|q| - opt[:verbose] = 0 - } } - parser.parse!(ARGV) + yamls = parser.parse!(ARGV) + yamls += BenchmarkDriver.new(opt).files + # Many variables in Makefile are not `foo,bar` but `foo bar`. So it's converted here. execs = opt[:execs].map { |exec| ['--executables', exec.shellsplit.join(',')] }.flatten - yamls = BenchmarkDriver.new(opt).files - BenchmarkDriver.run(*yamls, *execs, "--verbose=#{opt[:verbose]}", "--repeat-count=#{opt[:repeat]}") + rbenv = opt[:rbenvs].map { |r| ['--rbenv', r] } + + BenchmarkDriver.run( + *yamls, *execs, *rbenv, + "--runner=#{opt[:runner]}", "--output=#{opt[:output]}", + "--verbose=#{opt[:verbose]}", "--repeat-count=#{opt[:repeat]}", + ) end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/