Skip to content

Commit bbab1c2

Browse files
authored
Warn when two executables have the same revision and flags (#503)
When benchmarking two rubies that produce identical `ruby -v` output and use the same command-line flags, it's likely a user mistake. Skip the warning when JIT flags differ, since comparing JIT vs non-JIT on the same revision is a valid use case.
1 parent 4ab440a commit bbab1c2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/benchmark_runner/cli.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
module BenchmarkRunner
1111
class CLI
12+
BOLD = "\e[1m"
13+
RESET = "\e[0m"
14+
1215
attr_reader :args
1316

1417
def self.run(argv = ARGV)
@@ -45,6 +48,18 @@ def run
4548
ruby_descriptions[name] = `#{executable.shelljoin} -v`.chomp
4649
end
4750

51+
# Warn if two executables look identical (same ruby -v output and same flags)
52+
names = ruby_descriptions.keys
53+
names.each_with_index do |name_a, i|
54+
names[(i + 1)..].each do |name_b|
55+
flags_a = args.executables[name_a][1..] || []
56+
flags_b = args.executables[name_b][1..] || []
57+
if ruby_descriptions[name_a] == ruby_descriptions[name_b] && flags_a == flags_b
58+
warn "#{BOLD}WARNING: '#{name_a}' and '#{name_b}' appear identical (same revision, same flags). This is likely a mistake.#{RESET}"
59+
end
60+
end
61+
end
62+
4863
bench_start_time = Time.now.to_f
4964
bench_data = {}
5065
bench_failures = {}

0 commit comments

Comments
 (0)