summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-08 17:48:58 (GMT)
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-08 17:48:58 (GMT)
commitdc8327d79a7ce880dfef56116a3bca75eb888bc1 (patch)
tree40f0d2a781dcb10824c859b284dd1859e757249c /benchmark
parenta7681376e0861796411ee036d9b81c535581d810 (diff)
benchmark/driver.rb: drop legacy Ruby script support
Now all benchmarks are converted to YAMLs. common.mk: Drop obsoleted bm_* pattern git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rwxr-xr-xbenchmark/driver.rb68
1 files changed, 12 insertions, 56 deletions
diff --git a/benchmark/driver.rb b/benchmark/driver.rb
index 4185e20..b673a84 100755
--- a/benchmark/driver.rb
+++ b/benchmark/driver.rb
@@ -11,7 +11,6 @@ rescue LoadError
end
require 'shellwords'
-require 'tempfile'
class BenchmarkDriver
# Run benchmark-driver prepared by `make update-benchmark-driver`
@@ -23,69 +22,27 @@ class BenchmarkDriver
end
end
- def initialize(dir, opt = {})
- @dir = dir
- @pattern = opt[:pattern] || nil
- @exclude = opt[:exclude] || nil
- end
-
- def with_yamls(&block)
- ios = files.map do |file|
- Tempfile.open.tap do |io|
- if file.end_with?('.yml')
- io.write(File.read(file))
- else
- io.write(build_yaml(file))
- end
- io.close
- end
- end
- block.call(ios.map(&:path))
- ensure
- ios.each(&:close)
- end
-
- private
-
- def build_yaml(file)
- magic_comment = '# prelude' # bm_so_nsieve_bits hangs without magic comment
- name = File.basename(file).sub(/\Abm_/, '').sub(/\.rb\z/, '')
- script = File.read(file).sub(/^__END__\n(.+\n)*/m, '').sub(/\A(^#[^\n]+\n)+/m) do |comment|
- magic_comment = comment
- ''
- end
-
- <<-YAML
-prelude: |
-#{magic_comment.gsub(/^/, ' ')}
-benchmark:
- #{name}: |
-#{script.gsub(/^/, ' ')}
-loop_count: 1
- YAML
+ def initialize(opt = {})
+ @dir = opt[:dir]
+ @pattern = opt[:pattern]
+ @exclude = opt[:exclude]
end
def files
- flag = {}
- legacy_files = Dir.glob(File.join(@dir, 'bm*.rb'))
- yaml_files = Dir.glob(File.join(@dir, '*.yml'))
- files = (legacy_files + yaml_files).map{|file|
+ Dir.glob(File.join(@dir, '*.yml')).map{|file|
next if @pattern && /#{@pattern}/ !~ File.basename(file)
next if @exclude && /#{@exclude}/ =~ File.basename(file)
file
- }.compact
-
- files.sort!
- files
+ }.compact.sort
end
end
if __FILE__ == $0
opt = {
- :execs => [],
- :dir => File.dirname(__FILE__),
- :repeat => 1,
- :verbose => 1,
+ execs: [],
+ dir: File.dirname(__FILE__),
+ repeat: 1,
+ verbose: 1,
}
parser = OptionParser.new{|o|
@@ -123,7 +80,6 @@ if __FILE__ == $0
parser.parse!(ARGV)
execs = opt[:execs].map { |exec| ['--executables', exec.shellsplit.join(',')] }.flatten
- BenchmarkDriver.new(opt[:dir], opt).with_yamls do |yamls|
- BenchmarkDriver.run(*yamls, *execs, "--verbose=#{opt[:verbose]}", "--repeat-count=#{opt[:repeat]}")
- end
+ yamls = BenchmarkDriver.new(opt).files
+ BenchmarkDriver.run(*yamls, *execs, "--verbose=#{opt[:verbose]}", "--repeat-count=#{opt[:repeat]}")
end