Skip to content

Commit e93dccc

Browse files
committed
Check that the ruby configuration isn't changed during the benchmark
1 parent 06cf574 commit e93dccc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

harness/harness.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616

1717
system('mkdir', '-p', File.dirname(OUT_CSV_PATH))
1818

19+
def yjit_enabled?
20+
# We could add other values here if we discover any
21+
# but for now all we want to know is if YJIT was enabled at runtime.
22+
RubyVM::YJIT.enabled? if defined?(RubyVM::YJIT)
23+
end
24+
25+
ORIGINAL_YJIT_ENABLED = yjit_enabled?
26+
1927
puts RUBY_DESCRIPTION
2028

2129
def realtime
@@ -52,4 +60,8 @@ def run_benchmark(_num_itrs_hint, &block)
5260
non_warmups_ms = ((non_warmups.sum / non_warmups.size) * 1000.0).to_i
5361
puts "Average of last #{non_warmups.size}, non-warmup iters: #{non_warmups_ms}ms"
5462
end
63+
64+
if yjit_enabled? != ORIGINAL_YJIT_ENABLED
65+
raise "Benchmark altered YJIT configuration! (changed from #{ORIGINAL_YJIT_ENABLED.inspect} to #{yjit_enabled?.inspect})"
66+
end
5567
end

0 commit comments

Comments
 (0)