diff options
| author | Randy Stauner <randy.stauner@shopify.com> | 2024-09-17 17:06:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-17 20:06:27 -0400 |
| commit | 7c4b028435aa83ee42f3db2ecf47f53a1c2247cf (patch) | |
| tree | 0624e193606f66d83cd0bb66ef8199ec68709863 /test/ruby | |
| parent | 39679d7fabca7fe0918b538e746d5d4381862bce (diff) | |
YJIT: Accept key for runtime_stats to return only that stat (#11536)
Notes
Notes:
Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_yjit.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 96a6100717..c91d631256 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -1638,6 +1638,41 @@ class TestYJIT < Test::Unit::TestCase RUBY end + def test_runtime_stats_key_arg + assert_compiles(<<~'RUBY', exits: :any, result: true) + def test = :ok + 3.times { test } + + # Collect single stat. + stat = RubyVM::YJIT.runtime_stats(:ratio_in_yjit) + + # Ensure this invocation had stats. + return true unless RubyVM::YJIT.runtime_stats[:all_stats] + + stat > 0.0 + RUBY + end + + def test_runtime_stats_arg_error + assert_compiles(<<~'RUBY', exits: :any, result: true) + begin + RubyVM::YJIT.runtime_stats(Object.new) + :no_error + rescue TypeError => e + e.message == "non-symbol given" + end + RUBY + end + + def test_runtime_stats_unknown_key + assert_compiles(<<~'RUBY', exits: :any, result: true) + def test = :ok + 3.times { test } + + RubyVM::YJIT.runtime_stats(:some_key_unlikely_to_exist).nil? + RUBY + end + private def code_gc_helpers |
