summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-08 18:33:43 (GMT)
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-08 18:33:43 (GMT)
commit2a12b82dcd542ba5d68e117aae2ebffa2a266a99 (patch)
tree502128f557ca053b293ad0b71546a9a50b8d993f /benchmark
parent2cab2fc8b1aca2aeb655289122346dfebadd6cbc (diff)
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... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rwxr-xr-xbenchmark/driver.rb58
1 files changed, 39 insertions, 19 deletions
diff --git a/benchmark/driver.rb b/benchmark/driver.rb
index 53c8d60..2a4e3a6 100755
--- a/benchmark/driver.rb
+++ b/benchmark/driver.rb
@@ -39,13 +39,27 @@ end
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
}
}
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