diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2023-04-02 12:23:22 -0700 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2023-04-02 12:23:23 -0700 |
commit | 3fe134759cc4904c74306e0832c22fa518a5bea2 (patch) | |
tree | b75bbd787fca2c8c97a95aa808c6126c081958b8 /tool | |
parent | bf7587748d793265060fc2708421eaeddea7e4c0 (diff) | |
download | ruby-3fe134759cc4904c74306e0832c22fa518a5bea2.tar.gz |
Skip assert_linear_performance for RJIT
Diffstat (limited to 'tool')
-rw-r--r-- | tool/lib/core_assertions.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tool/lib/core_assertions.rb b/tool/lib/core_assertions.rb index 1fdc0a34b8..c5b4089862 100644 --- a/tool/lib/core_assertions.rb +++ b/tool/lib/core_assertions.rb @@ -744,13 +744,16 @@ eom # # :yield: each elements of +seq+. def assert_linear_performance(seq, rehearsal: nil, pre: ->(n) {n}) + # Timeout testing generally doesn't work when RJIT compilation happens. + rjit_enabled = defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? + first = seq.first *arg = pre.call(first) times = (0..(rehearsal || (2 * first))).map do st = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield(*arg) t = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st) - assert_operator 0, :<=, t + assert_operator 0, :<=, t unless rjit_enabled t.nonzero? end times.compact! @@ -766,7 +769,7 @@ eom Timeout.timeout(t, Timeout::Error, message) do st = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield(*arg) - assert_operator (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st), :<=, t, message + assert_operator (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st), :<=, t, message unless rjit_enabled end end end |