summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-04-02 12:23:22 -0700
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2024-09-10 16:00:29 +0900
commitafbae64f05e4d90037be3152a105632ceb80c1b4 (patch)
treedfe82700683375843945129d9cc9feac7c8863ed
parent8562b665f3cbecfbbd05ca1e4ee7242c583a0898 (diff)
Skip assert_linear_performance for RJIT
-rw-r--r--tool/lib/core_assertions.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/tool/lib/core_assertions.rb b/tool/lib/core_assertions.rb
index 5ae9019c46..66f5d9ec53 100644
--- a/tool/lib/core_assertions.rb
+++ b/tool/lib/core_assertions.rb
@@ -732,13 +732,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!
@@ -754,7 +757,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