Skip to content

Commit 9ff1fd0

Browse files
voidstackloopclaude
andcommitted
Enrich the benchmarks: concurrency and screenshot sweeps
BENCHMARKS.md was stale (checked-in numbers said "eight built-in checks" / 280 checks-per-run; three checks were added this session, so it's actually eleven / 385) and its two most load-bearing claims - "concurrency matters more than raw speed" and "screenshots cost something" - were prose assertions with no number behind either one. scripts/benchmark.sh already had the machinery (build release binary, serve the demo site, time repeated `monitor` runs); it just hardcoded --max-concurrent 4 and never passed --no-screenshots. Added MAX_CONCURRENT and NO_SCREENSHOTS env vars (mirroring the existing RUNS/WAIT/PORT pattern) and two matching columns in the printed table, then swept both: - concurrency 1 -> 4 (default) -> 8: 47.4s -> 13.4s -> 8.1s median. Confirms the claim with an actual ~3.5x number instead of just asserting it, and shows the expected tapering gain from 4 to 8 as CPU/Chrome-process contention grows. - screenshots on vs off at the default concurrency: 13.4s vs 12.6s - real, but a modest ~6%, not the dominant cost the old prose implied without a number to back it. Refreshed the checked-in table with real re-measured rows for all four combinations rather than just editing the stale numbers by hand, and rewrote "Reading the numbers" to cite the actual deltas. All on the same machine/Chromium revision as the existing numbers, so they're directly comparable - no new environment section needed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 078a9d7 commit 9ff1fd0

2 files changed

Lines changed: 46 additions & 20 deletions

File tree

‎BENCHMARKS.md‎

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@ a clean baseline plus a page for every check and known edge case — and
99
`monitor demo-sites/forms.yml` checks all of them.
1010

1111
Because everything is served from `127.0.0.1`, there's no network latency in
12-
these numbers — what's left is browser launch, the eight built-in checks per
12+
these numbers — what's left is browser launch, the eleven built-in checks per
1313
form, screenshot capture, and report writing.
1414

1515
## Latest results
1616

17-
Measured with `RUNS=5 WAIT=1 scripts/benchmark.sh` (median of 5 runs, after
18-
one warm-up run):
17+
Measured with `scripts/benchmark.sh` (median of the given number of runs,
18+
after one warm-up run), sweeping the two knobs the "Reading the numbers"
19+
section below used to only assert about:
1920

20-
| Forms | Checks/run | Runs | `--wait` | min (s) | median (s) | max (s) | forms/min | checks/s |
21-
|------:|-----------:|-----:|---------:|--------:|-----------:|--------:|----------:|---------:|
22-
| 35 | 280 | 5 | 1s | 12.93 | 12.96 | 13.19 | 162.0 | 21.6 |
21+
| Forms | Checks/run | Runs | `--wait` | Concurrency | Screenshots | min (s) | median (s) | max (s) | forms/min | checks/s |
22+
|------:|-----------:|-----:|---------:|------------:|:------------|--------:|-----------:|--------:|----------:|---------:|
23+
| 35 | 385 | 5 | 1s | 4 (default) | on | 12.78 | 13.36 | 13.59 | 157.2 | 28.8 |
24+
| 35 | 385 | 5 | 1s | 4 (default) | off | 12.03 | 12.61 | 12.93 | 166.5 | 30.5 |
25+
| 35 | 385 | 5 | 1s | 1 | on | 47.21 | 47.44 | 47.66 | 44.3 | 8.1 |
26+
| 35 | 385 | 3 | 1s | 8 | on | 7.87 | 8.05 | 8.12 | 260.9 | 47.8 |
2327

2428
The 35 demo forms cover a clean baseline, a failing page for most checks, a
2529
three-step wizard and its slow/keyup/icon-only variants, shadow-DOM and
@@ -34,13 +38,14 @@ realistic mix, not 35 trivial pages.
3438
- OS: Ubuntu on WSL2
3539
- Chromium (`~/.cache/formwatch/chrome`): 107.0.5296.0
3640
- Rust: 1.98.1
37-
- `--max-concurrent 4` (the default)
3841

3942
## Reproduce
4043

4144
```
42-
scripts/benchmark.sh # 5 runs, --wait 1
43-
RUNS=10 WAIT=0 scripts/benchmark.sh # more runs, no idle wait
45+
scripts/benchmark.sh # 5 runs, --wait 1, --max-concurrent 4
46+
RUNS=10 WAIT=0 scripts/benchmark.sh # more runs, no idle wait
47+
MAX_CONCURRENT=1 scripts/benchmark.sh # sweep concurrency
48+
NO_SCREENSHOTS=1 scripts/benchmark.sh # isolate screenshot cost
4449
PORT=9001 WAIT=3 scripts/benchmark.sh
4550
```
4651

@@ -54,12 +59,18 @@ Everything is local; it never contacts a third-party site.
5459
`--wait` seconds (1s here; the default is 5s). That is deliberate idle
5560
time, not overhead — set `WAIT=0` to see the floor. Real `monitor` runs
5661
against remote forms add page-load time on top.
57-
- **Concurrency matters more than raw speed.** `--max-concurrent` (default
58-
4) multiplies throughput on multi-core machines at the cost of running
59-
more browsers at once; the per-host pacer (`--per-host-delay-ms`) is the
60-
polite counterweight.
61-
- **Screenshots cost something.** Every non-Pass check captures a full-page
62-
PNG; `--no-screenshots` trades evidence for speed.
62+
- **Concurrency matters far more than raw speed.** Going from
63+
`--max-concurrent 1` to the default `4` cut the median from 47.4s to
64+
13.4s on this 16-thread machine — a ~3.5x speedup from running more
65+
browsers at once, not from anything getting individually faster.
66+
`--max-concurrent 8` cut it further to 8.1s, though gains taper as
67+
contention for CPU/Chrome processes grows; the per-host pacer
68+
(`--per-host-delay-ms`) is the polite counterweight when checking a real,
69+
shared third-party host rather than a local demo server.
70+
- **Screenshots cost something, but modestly**: 13.4s with screenshots vs.
71+
12.6s with `--no-screenshots` on this same demo mix — about 6%, worth
72+
knowing but not the dominant cost. Every non-Pass check captures a
73+
full-page PNG; `--no-screenshots` trades that evidence for the difference.
6374
- **A failing page is slower than a passing one** (screenshots plus the
6475
extra validation work), which is why the demo mix matters.
6576

‎scripts/benchmark.sh‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env bash
22
# Benchmark formwatch against the bundled demo site.
33
#
4-
# scripts/benchmark.sh # 5 timed runs, default port/wait
4+
# scripts/benchmark.sh # 5 timed runs, default port/wait
55
# RUNS=10 WAIT=0 PORT=9001 scripts/benchmark.sh
6+
# MAX_CONCURRENT=1 scripts/benchmark.sh # sweep concurrency
7+
# NO_SCREENSHOTS=1 scripts/benchmark.sh # isolate screenshot cost
68
#
79
# Starts `formwatch demo` on localhost, then repeatedly runs `monitor` over
810
# every demo form and reports wall-clock timings. Everything is local, so
@@ -15,10 +17,17 @@ cd "$(dirname "$0")/.."
1517
PORT="${PORT:-8099}"
1618
RUNS="${RUNS:-5}"
1719
WAIT="${WAIT:-1}"
20+
MAX_CONCURRENT="${MAX_CONCURRENT:-4}"
21+
NO_SCREENSHOTS="${NO_SCREENSHOTS:-0}"
1822
ADDR="127.0.0.1:${PORT}"
1923
BIN="./target/release/formwatch"
2024
HIST="$(mktemp -d)/history"
2125

26+
SCREENSHOT_FLAG=()
27+
if [ "$NO_SCREENSHOTS" = "1" ]; then
28+
SCREENSHOT_FLAG=(--no-screenshots)
29+
fi
30+
2231
echo "building release binary…" >&2
2332
cargo build --release -q
2433

@@ -33,7 +42,8 @@ done
3342

3443
run_once() {
3544
"$BIN" --history-dir "$HIST" monitor demo-sites/forms.yml \
36-
--wait "$WAIT" --max-concurrent 4 --json >/tmp/formwatch-bench.json 2>/dev/null || true
45+
--wait "$WAIT" --max-concurrent "$MAX_CONCURRENT" "${SCREENSHOT_FLAG[@]}" --json \
46+
>/tmp/formwatch-bench.json 2>/dev/null || true
3747
}
3848

3949
run_once # warm-up (Chrome launch, page cache)
@@ -56,7 +66,12 @@ median=$(awk -v n="$RUNS" 'NR == int((n + 1) / 2) { print; exit }' /tmp/formwatc
5666
forms_per_min=$(awk -v f="$forms" -v m="$median" 'BEGIN { printf "%.1f", (f / m) * 60 }')
5767
checks_per_sec=$(awk -v c="$checks" -v m="$median" 'BEGIN { printf "%.1f", c / m }')
5868

69+
screenshots_label="on"
70+
if [ "$NO_SCREENSHOTS" = "1" ]; then
71+
screenshots_label="off"
72+
fi
73+
5974
echo
60-
echo "| Forms | Checks/run | Runs | Wait | min (s) | median (s) | max (s) | forms/min | checks/s |"
61-
echo "|------:|-----------:|-----:|-----:|--------:|-----------:|--------:|----------:|---------:|"
62-
echo "| $forms | $checks | $RUNS | ${WAIT}s | $min | $median | $max | $forms_per_min | $checks_per_sec |"
75+
echo "| Forms | Checks/run | Runs | Wait | Concurrency | Screenshots | min (s) | median (s) | max (s) | forms/min | checks/s |"
76+
echo "|------:|-----------:|-----:|-----:|------------:|:------------|--------:|-----------:|--------:|----------:|---------:|"
77+
echo "| $forms | $checks | $RUNS | ${WAIT}s | $MAX_CONCURRENT | $screenshots_label | $min | $median | $max | $forms_per_min | $checks_per_sec |"

0 commit comments

Comments
 (0)