Skip to content

Commit

Permalink
Improve base time of assert_linear_performance (ruby#11369)
Browse files Browse the repository at this point in the history
Remove `.ceil` from base time calculation that makes 10x gap.
This will make the assertion more strict and also less flaky.
  • Loading branch information
tompng authored and hsbt committed Sep 10, 2024
1 parent b7e418b commit 11f5e6c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tool/lib/core_assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,9 @@ def assert_linear_performance(seq, rehearsal: nil, pre: ->(n) {n})
end
times.compact!
tmin, tmax = times.minmax
tbase = 10 ** Math.log10(tmax * ([(tmax / tmin), 2].max ** 2)).ceil

# safe_factor * tmax * rehearsal_time_variance_factor(equals to 1 when variance is small)
tbase = 10 * tmax * [(tmax / tmin) ** 2 / 4, 1].max
info = "(tmin: #{tmin}, tmax: #{tmax}, tbase: #{tbase})"

seq.each do |i|
Expand Down

0 comments on commit 11f5e6c

Please sign in to comment.