Skip to content

Commit 7b6b1e1

Browse files
authored
Merge pull request #329 from Shopify/rwstauner/check-ruby-config
Check that the ruby configuration isn't changed during the benchmark
2 parents 06cf574 + c75deec commit 7b6b1e1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

harness/harness.rb

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

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

19+
# We could include other values in this result if more become relevant
20+
# but for now all we want to know is if YJIT was enabled at runtime.
21+
def yjit_enabled?
22+
RubyVM::YJIT.enabled? if defined?(RubyVM::YJIT)
23+
end
24+
ORIGINAL_YJIT_ENABLED = yjit_enabled?
25+
1926
puts RUBY_DESCRIPTION
2027

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

0 commit comments

Comments
 (0)