summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbenchmark/driver.rb68
-rw-r--r--common.mk2
2 files changed, 13 insertions, 57 deletions
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
diff --git a/common.mk b/common.mk
index dd1f7a7102..b3b0972432 100644
--- a/common.mk
+++ b/common.mk
@@ -1123,7 +1123,7 @@ benchmark: miniruby$(EXEEXT) update-benchmark-driver PHONY
$(BASERUBY) $(srcdir)/benchmark/driver.rb \
--executables="compare-ruby::$(COMPARE_RUBY) -I$(EXTOUT)/common --disable-gem" \
--executables="built-ruby::$(MINIRUBY) -r$(srcdir)/prelude --disable-gem" \
- --pattern='bm_' --directory=$(srcdir)/benchmark $(OPTS)
+ --directory=$(srcdir)/benchmark $(OPTS)
benchmark-each: miniruby$(EXEEXT) update-benchmark-driver PHONY
$(BASERUBY) $(srcdir)/benchmark/driver.rb \