From 8bd8cac9ef1d24899aba952b178602da56cede3d Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 11:06:29 -1000 Subject: Time the other filters at two lengths as well The avatar checks held a 40000 byte address to half a second, twenty times tighter than the readme budget that already failed on a slow host, and in stub mode nearly all of that time went on the fake digest. Link-commits and link-trailers had no check on a long input at all. The readme checks' method moves into the harness so all four share it. A single timing of each length let a busy host that took the CPU away during the longer one make a linear pass look quadratic. The lengths now take turns and the fastest timing of each counts, since a busy host can slow one timing but rarely all five. A ratio under six ends the turns at once, so only one near the bound of ten waits for all five. --- tests/extensions/test-email-avatar.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/extensions/test-email-avatar.lua') diff --git a/tests/extensions/test-email-avatar.lua b/tests/extensions/test-email-avatar.lua index 5929634..c9a9ec0 100644 --- a/tests/extensions/test-email-avatar.lua +++ b/tests/extensions/test-email-avatar.lua @@ -101,14 +101,14 @@ h.contains("a name keeps the escaping cgit gave it", out, "> A & B") h.excludes("and is not escaped again", out, "&amp;") -- A commit can carry any bytes in its address, and a log page runs the --- filter once per row, so the trim has to stay linear in a run of spaces. -local started = os.clock() -render("", "x") -h.check("a long run of inner spaces is trimmed quickly", os.clock() - started < 0.5) - -started = os.clock() -render(string.rep("<", 40000), "x") -h.check("a long run of open brackets is unwrapped quickly", os.clock() - started < 0.5) +-- filter once per row, so trimming and unwrapping have to stay linear. +local function address_only(text) + return (render(text, "x")) +end +h.stays_linear("a long run of inner spaces is trimmed in linear time", address_only, + function(count) return "" end, 10000) +h.stays_linear("an address of open brackets is scanned in linear time", address_only, + function(count) return string.rep("<", count) end, 10000) h.check("text around the brackets is dropped", hash_of(render("x y", "x")) == plain) -- cgit 2.12.1