r/rust • • Aug 23 '26

🛠️ project [ Removed by moderator ]

[removed] — view removed post

0 Upvotes

5 comments sorted by

-4

u/[deleted] Aug 23 '26

[removed] — view removed comment

-3

u/Top_Introduction_865 Aug 23 '26

Good question, so I measured it rather than guessed.

Setup: same Chrome binary for both (chrome-headless-shell 152.0.7977.54), a
local static file:// page so there's no network variance, both producing an
identical 1320x2868 PNG. puppeteer-core 25.8.0 on node v24. 2-core Xeon
@2.9GHz, so treat the absolute numbers as slow-machine numbers and the ratios
as the interesting part. Median of 5-7 cold runs each.

One device, cold process to written file:

puppeteer waitUntil: networkidle0 1.14 s
puppeteer waitUntil: load 0.46 s
puppeteer waitUntil: domcontentloaded 0.45 s
proofsheet 0.26 s

The first line is the one you'd get from copy-pasting a typical screenshot
snippet, but it's not a fair comparison: networkidle0 includes a 500ms idle
wait by definition. Against waitUntil: load it's 0.46s vs 0.26s, so roughly
1.8x, not the 4x the naive comparison suggests.

Where that 0.2s actually goes, since "Rust is faster" isn't the answer:

node -e '' 0.02 s bare interpreter
node -e 'require("puppeteer")' 0.13 s + module graph
proofsheet version 0.00 s (rounds to zero)

So ~0.13s is Node startup plus resolving puppeteer's module graph, before any
browser work happens at all. The rest is that puppeteer does more at launch …
temp profile setup, a broader CDP handshake, more round trips. Dropping the
async runtime isn't where the win comes from; CDP is a request/response
protocol over one socket, and the concurrency a runtime buys you has nothing
to do at that point.

AND HERE IS WHERE IT LOSES, which is the more useful half of the answer.

Five devices, puppeteer reusing one browser across five pages vs proofsheet:

puppeteer 1 browser, 5 pages 0.99 s
proofsheet 5 browsers 1.11 s

proofsheet is slower, and it's deliberate: it launches one browser process per
device. Emulation overrides leak between pages in the same process in ways I
couldn't fully close off …you set metrics + UA + touch for a phone, then a
tablet page inherits something it shouldn't, and you get a subtly wrong
screenshot that still passes every dimension check. Given the whole point is
"the image is provably the right thing", I took the process-per-device cost
over that risk.

So the honest summary: ~2x faster to first screenshot, slightly slower across
a matrix, and the per-device cost is linear where puppeteer's amortizes. If
you're capturing one thing in a hot process, puppeteer's fine. The startup win
matters for CI and for one-shot CLI invocations, which is what this is for.

If you think the process-per-device thing is me being paranoid and there's a
clean way to reset emulation state between pages, I'd genuinely like to hear
it …that's the one number in there I'd most like to improve.

Benchmark scripts are trivial (a puppeteer launch + setViewport + goto +
screenshot, and the equivalent CLI invocation); happy to paste them if anyone
wants to poke holes in the methodology.

5

u/crumb_factory Aug 23 '26

low-effort slop

1

u/Top_Introduction_865 Aug 25 '26

Stop downplaying my awesomeness to make yourself feel some type of way. You’re pathetic