Skip to content

Commit

Permalink
Merge pull request #329 from Shopify/rwstauner/check-ruby-config
Browse files Browse the repository at this point in the history
Check that the ruby configuration isn't changed during the benchmark
  • Loading branch information
rwstauner authored Sep 17, 2024
2 parents 06cf574 + c75deec commit 7b6b1e1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions harness/harness.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

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

# We could include other values in this result if more become relevant
# but for now all we want to know is if YJIT was enabled at runtime.
def yjit_enabled?
RubyVM::YJIT.enabled? if defined?(RubyVM::YJIT)
end
ORIGINAL_YJIT_ENABLED = yjit_enabled?

puts RUBY_DESCRIPTION

def realtime
Expand Down Expand Up @@ -52,4 +59,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 7b6b1e1

Please sign in to comment.