diff --git a/benchmark/README.md b/benchmark/README.md index 9f9192685e9..02b6373f810 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -62,8 +62,7 @@ make benchmark ITEM=vm # Run some limited benchmarks in ITEM-matched files make benchmark ITEM=vm OPTS=--filter=block -# You can specify the benchmark by an exact filename instead of using the default argument: -# ARGS = $$(find $(srcdir)/benchmark -maxdepth 1 -name '*$(ITEM)*.yml' -o -name '*$(ITEM)*.rb') +# You can specify the benchmark by exact filenames instead of matching ITEM: make benchmark ARGS=benchmark/erb_render.yml # You can specify any option via $OPTS diff --git a/common.mk b/common.mk index 4e42dec02ef..9241631e972 100644 --- a/common.mk +++ b/common.mk @@ -1440,15 +1440,24 @@ COMPARE_RUBY = $(BASERUBY) BENCH_RUBY = $(RUNRUBY) BENCH_OPTS = --output=markdown --output-compare -v ITEM = -ARGS = $$(find $(srcdir)/benchmark -maxdepth 1 -name '$(ITEM)' -o -name '*$(ITEM)*.yml' -o -name '*$(ITEM)*.rb' | sort) +ARGS = OPTS = -# See benchmark/README.md for details. +# Select the benchmark files with Ruby instead of `find | sort`, so the +# recipe runs on any platform regardless of the shell. When ARGS is +# empty, collect the files matching ITEM under benchmark/. Executables +# are passed with forward slashes because benchmark-driver splits them +# with Shellwords, which eats backslashes. See benchmark/README.md. benchmark: miniruby$(EXEEXT) update-benchmark-driver PHONY - $(BASERUBY) -rrubygems -I$(srcdir)/benchmark/lib $(srcdir)/benchmark/benchmark-driver/exe/benchmark-driver \ - --executables="compare-ruby::$(COMPARE_RUBY) -I$(EXTOUT)/common --disable-gem" \ - --executables="built-ruby::$(BENCH_RUBY) --disable-gem" \ - $(BENCH_OPTS) $(ARGS) $(OPTS) + $(BASERUBY) -rrubygems -I$(srcdir)/benchmark/lib \ + -e "files = %w[$(ARGS)]" \ + -e "files = Dir.glob(['$(ITEM)', '*$(ITEM)*.yml', '*$(ITEM)*.rb'], base: '$(srcdir)/benchmark').reject(&:empty?).sort.uniq.map {|f| '$(srcdir)/benchmark/' + f} if files.empty?" \ + -e "ARGV.map! {|a| a.start_with?('--executables') ? a.gsub(92.chr, '/') : a}" \ + -e "ARGV.concat(files)" \ + -e "load '$(srcdir)/benchmark/benchmark-driver/exe/benchmark-driver'" -- \ + --executables="compare-ruby::$(COMPARE_RUBY) -I$(EXTOUT)/common --disable-gem" \ + --executables="built-ruby::$(BENCH_RUBY) --disable-gem" \ + $(BENCH_OPTS) $(OPTS) run.gdb: echo set breakpoint pending on > run.gdb