summaryrefslogtreecommitdiff
path: root/tool/lib/core_assertions.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <[email protected]>2023-03-16 09:22:42 -0700
committerTakashi Kokubun <[email protected]>2023-03-16 09:22:42 -0700
commita8e7fee80129b0ba360c2671582117c8e18a6464 ()
treebc95c4dbeb9b481f0b8e110a4e2407f2aa04fa3b /tool/lib/core_assertions.rb
parent2f81bb793fd217374054ee78cb5cd595cfacf9fe (diff)
Revert "core_assertions.rb: Refine `assert_linear_performance`"
This reverts commit cae4342dd559e34c1ce6219593f77f0ad80286da. This is failing a lot of CIs and nobody is actively looking into fixing it. Let me revert this until we have a solution to it.
-rw-r--r--tool/lib/core_assertions.rb27
1 files changed, 11 insertions, 16 deletions
@@ -738,28 +738,23 @@ eom
end
alias all_assertions_foreach assert_all_assertions_foreach
- # Expect +seq+ to respond to +first+ and +each+ methods, e.g.,
- # Array, Range, Enumerator::ArithmeticSequence and other
- # Enumerable-s, and each elements should be size factors.
- #
- # :yield: each elements of +seq+.
- def assert_linear_performance(seq, rehearsal: nil, pre: ->(n) {n})
- first = seq.first
- *arg = pre.call(first)
- tmax = (0..(rehearsal || first)).map do
st = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- yield(*arg)
(Process.clock_gettime(Process::CLOCK_MONOTONIC) - st)
end.max
- seq.each do |i|
- next if i == first
- t = tmax * i / first
- *arg = pre.call(i)
- message = "[#{i}]: in #{t}s"
Timeout.timeout(t, nil, message) do
st = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- yield(*arg)
assert_operator (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st), :<=, t, message
end
end