From dc8327d79a7ce880dfef56116a3bca75eb888bc1 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Sun, 8 Jul 2018 17:48:58 +0000 Subject: 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 --- benchmark/driver.rb | 68 ++++++++++------------------------------------------- 1 file changed, 12 insertions(+), 56 deletions(-) (limited to 'benchmark') diff --git a/benchmark/driver.rb b/benchmark/driver.rb index 4185e20232..b673a84ca0 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 -- cgit v1.2.3