diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-03-15 18:19:31 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-03-15 18:19:31 +0900 |
commit | 09041a6ee8aadf8d87cc57d8546f134861bbcb8f (patch) | |
tree | 12b4b49daa661733c1859da9190f79f9d4bc4b14 /tool | |
parent | ca437aeb395e77125fcd2ab9bc83bbcd3e357610 (diff) | |
download | ruby-09041a6ee8aadf8d87cc57d8546f134861bbcb8f.tar.gz |
core_assertions.rb: Refine `assert_linear_performance`
* Add `rehearsal` keyword argument
* Stop repeating with the same factor
Diffstat (limited to 'tool')
-rw-r--r-- | tool/lib/core_assertions.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/tool/lib/core_assertions.rb b/tool/lib/core_assertions.rb index 12bff170b1..119deccb9f 100644 --- a/tool/lib/core_assertions.rb +++ b/tool/lib/core_assertions.rb @@ -738,17 +738,16 @@ eom end alias all_assertions_foreach assert_all_assertions_foreach - def assert_linear_performance(factor: 10_000, first: factor, max: 2, pre: ->(n) {n}) + def assert_linear_performance(factor: 10_000, first: factor, max: 2, rehearsal: first, pre: ->(n) {n}) n = first arg = pre.call(n) - tmax = (0..factor).map do + tmax = (0..rehearsal).map do st = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield arg (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st) end.max - 1.upto(max) do |i| - i += 1 if first >= factor + (first >= factor ? 2 : 1).upto(max) do |i| n = i * factor t = tmax * factor arg = pre.call(n) |