Skip to content

Commit

Permalink
Check that the ruby configuration isn't changed during the benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
rwstauner committed Sep 12, 2024
1 parent 06cf574 commit e93dccc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions harness/harness.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

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

def yjit_enabled?
# We could add other values here if we discover any
# but for now all we want to know is if YJIT was enabled at runtime.
RubyVM::YJIT.enabled? if defined?(RubyVM::YJIT)
end

ORIGINAL_YJIT_ENABLED = yjit_enabled?

puts RUBY_DESCRIPTION

def realtime
Expand Down Expand Up @@ -52,4 +60,8 @@ def run_benchmark(_num_itrs_hint, &block)
non_warmups_ms = ((non_warmups.sum / non_warmups.size) * 1000.0).to_i
puts "Average of last #{non_warmups.size}, non-warmup iters: #{non_warmups_ms}ms"
end

if yjit_enabled? != ORIGINAL_YJIT_ENABLED
raise "Benchmark altered YJIT configuration! (changed from #{ORIGINAL_YJIT_ENABLED.inspect} to #{yjit_enabled?.inspect})"
end
end

0 comments on commit e93dccc

Please sign in to comment.