Skip assert_linear_performance for RJIT

This commit is contained in:
Takashi Kokubun 2023-04-02 12:23:22 -07:00 committed by Hiroshi SHIBATA
parent 8562b665f3
commit afbae64f05

View file

@ -732,13 +732,16 @@ eom
# #
# :yield: each elements of +seq+. # :yield: each elements of +seq+.
def assert_linear_performance(seq, rehearsal: nil, pre: ->(n) {n}) 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 first = seq.first
*arg = pre.call(first) *arg = pre.call(first)
times = (0..(rehearsal || (2 * first))).map do times = (0..(rehearsal || (2 * first))).map do
st = Process.clock_gettime(Process::CLOCK_MONOTONIC) st = Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield(*arg) yield(*arg)
t = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st) t = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st)
assert_operator 0, :<=, t assert_operator 0, :<=, t unless rjit_enabled
t.nonzero? t.nonzero?
end end
times.compact! times.compact!
@ -754,7 +757,7 @@ eom
Timeout.timeout(t, Timeout::Error, message) do Timeout.timeout(t, Timeout::Error, message) do
st = Process.clock_gettime(Process::CLOCK_MONOTONIC) st = Process.clock_gettime(Process::CLOCK_MONOTONIC)
yield(*arg) 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 end
end end