Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to 'tests/extensions/test-about-render.lua')
| -rw-r--r-- | tests/extensions/test-about-render.lua | 23 |
1 file changed, 5 insertions, 18 deletions
diff --git a/tests/extensions/test-about-render.lua b/tests/extensions/test-about-render.lua index a08de66..cdba28a 100644 --- a/tests/extensions/test-about-render.lua +++ b/tests/extensions/test-about-render.lua @@ -266,25 +266,12 @@ out = render("README.md", "**__*_x_*__**") h.contains("every kind of emphasis nests in the others", out, "<p><strong><strong><em><em>x</em></em></strong></strong></p>") --- A hostile readme must cost about four times as much at four times the --- length, as a linear pass does, where a quadratic one costs sixteen times --- as much and holds a request for minutes near the size cap. Timing one --- length against the other cancels out how fast the host is, and each --- render repeats until it is long enough to time. -local function seconds(filename, text) - local runs, started, out = 0, os.clock(), nil - repeat - out = render(filename, text) - runs = runs + 1 - until os.clock() - started >= 0.02 - return (os.clock() - started) / runs, out -end - +-- A hostile readme that renders in more than linear time holds a request +-- for minutes near the size cap. local function stays_linear(name, filename, make, length) - local short = seconds(filename, make(length)) - local long, out = seconds(filename, make(4 * length)) - h.check(name, long < 10 * short, - string.format("%.4f s at length %d, then %.4f s at four times that", short, length, long)) + local out = h.stays_linear(name, function(text) + return render(filename, text) + end, make, length) h.equals(name .. " and still renders as markup", out:sub(1, 22), "<div class='markdown'>") end |
