# Python vs Rust for browser automation: a benchmark
I needed to pick a tool for a browser-automation workload: launch a headless browser,
navigate, wait for a page to render, take a screenshot, extract some data, and do that a
very large number of times. The obvious choice is Python with Playwright. Before committing
to it I wanted actual numbers, so I built the same task three ways and measured them against
each other on identical hardware and identical pages.
This repo is the harness and the results. Everything here is reproducible; the "Reproduce it"
section at the bottom is the whole method.
## The three tools
- **Python + Playwright** (`playwright==1.60.0`) — the standard, best-documented option.
- **Rust + playwright-rs** (`0.14.1`) — a Rust binding to Playwright.
- **Rust + chromiumoxide** — a native Rust client that speaks the Chrome DevTools Protocol
directly to the browser.
There is one architectural detail that explains most of the results, and it is worth stating
up front: **Python-Playwright and Rust-playwright-rs both drive the browser through the same
Node.js Playwright driver.** They are two different front-ends bolted onto the identical
engine. So the gap between those two is only the thin binding layer. chromiumoxide has no such
middleman — it talks to the browser directly. Most of the difference you see below comes from
removing that Node.js layer, not from "Rust being fast."
## Results at a glance
| | Python | playwright-rs | chromiumoxide |
|---|---|---|---|
| One screenshot (median) | 824 ms | 736 ms | **599 ms** |
| 50 captures in parallel (median) | 1507 ms | 1201 ms | **947 ms** |
| Memory per run | 150-350 MB | 10-25 MB | **6-17 MB** |
| Work dropped at 50-way concurrency | 9.5% | 29% | **0%** |
| Browser launch time | ~250 ms | ~250 ms | **~75 ms** |
Same ordering in every scenario: chromiumoxide fastest, playwright-rs in the middle, Python
last. The interesting part is the shape of it — see below.
## What gets measured
Every run records, from outside the process (`/usr/bin/time`):
- `proc_wall_ms` — total wall-clock time for the whole process, startup included.
- `peak_rss_bytes` — peak memory.
And from inside:
- `t_launch_ms` — time to start the browser and get a usable page.
- `t_work_ms` — time to do the actual task.
- a correctness value — a checksum for data-extraction tasks, or a SHA-256 of the screenshot
bytes for capture tasks. A run whose output does not match the expected value is discarded,
never averaged in.
The method is deliberately careful so the numbers are trustworthy:
- The three tools are **interleaved** (round-robin), never run in separate blocks, so thermal
drift or background load hits all three equally.
- The first few iterations of every scenario are **warmup** and thrown away.
- Every scenario is run 100 times per tool; the report keeps the full distribution
(median, p90, p99, standard deviation), not just the mean.
- Differences are checked with a Mann-Whitney U test.
## Local benchmark (synthetic pages)
These run against small local HTML pages served from `server/`, so there is zero network
noise — the numbers reflect the tools, not the internet. Measured on Apple Silicon.
Median wall-clock per run, in milliseconds (lower is better):
| Scenario | What it does | Python | playwright-rs | chromiumoxide |
|---|---|--:|--:|--:|
| nav | open a page, read title + text | 426 | 325 | **128** |
| extract500 | scrape 500 items | 368 | 285 | **117** |
| extract5000 | scrape 5000 items | 501 | 405 | **197** |
| domwalk100 | read 100 elements one by one | 618 | 454 | **234** |
| shot1 | one screenshot | 824 | 736 | **599** |
| shot10 | ten screenshots | 1724 | 1649 | **1383** |
| conc10 | 10 pages in parallel | 826 | 671 | **389** |
| conc20 | 20 pages in parallel | 1197 | 971 | **686** |
| conc50 | 50 pages in parallel | 1507 | 1201 | **947** |
**Memory** is the largest and most consistent gap. Python holds 150-350 MB per run depending
on the scenario; both Rust tools stay in the 10-25 MB range. At 50-way concurrency the split is
349 MB (Python) versus 10-15 MB (Rust) for identical work. That difference decides how many
workers fit on one machine.
**Reliability under load.** Only the concurrency scenarios expose this. Out of every parallel
sub-task attempted, how many silently failed:
| | Python | playwright-rs | chromiumoxide |
|---|---|---|---|
| 10 parallel (1000 tasks) | 0% | 0% | 0% |
| 20 parallel (2000 tasks) | 1.0% | 5.3% | 0% |
| 50 parallel (5000 tasks) | 9.5% | 29% | 0% |
This is the one result that is not a straight "Rust wins." At heavy concurrency, playwright-rs
was the *least* reliable of the three, dropping nearly a third of its work, while chromiumoxide
dropped nothing. The lesson is that the specific library matters more than the language.
## Real Google Maps capture
The synthetic pages are clean but artificial. As a realistic, network-heavy target I also ran
the screenshot task against Google Maps satellite view, used purely as a test and research
target: navigate to a lat/long in satellite mode, wait for tiles to load, capture. 300 captures
per tool across 18 cities, run on a 32-core ARM64 Linux VM.
| | Python | playwright-rs | chromiumoxide |
|---|---|---|---|
| Time per capture (median) | 9.09 s | 9.22 s | **8.56 s** |
| Captures per minute (one at a time) | 6.6 | 6.5 | **7.0** |
| Browser launch time | 373 ms | 366 ms | **76 ms** |
| Memory per capture | 166 MB | 11 MB | **12.6 MB** |
Two honest observations from this run:
- On a real page the **speed gap between the tools nearly disappears** — all three sit around
8.5-9.2 seconds, because the fixed 8-second wait for satellite tiles to stream in dominates
everything the tool itself does. The tool's own overhead only matters when the page is fast.
- The **memory gap holds exactly** — Python stays roughly 13-15x heavier per capture, on a
completely different machine and OS than the local benchmark.
All three capture the identical region and frame (image sizes agree to within 0.1%), and none
of the tools was ever blocked or shown a captcha across the 900 captures.
## What I concluded
For this workload, **chromiumoxide** is the pick: fastest in every scenario, roughly 10-15x
lighter on memory, and the only one of the three that dropped no work under heavy concurrency.
The honest trade-off is that chromiumoxide is lower-level than Playwright. It has a smaller
feature set and no built-in text-based auto-waiting, so you write more of the wait/retry/error
handling yourself. If developer time mattered more than performance and scale, Python-Playwright
would be the pragmatic choice — its ecosystem and ergonomics are the best of the three. The gap
that would actually change my mind at scale is memory and reliability, and those both point one
way.
## Caveats
- The local numbers are from Apple Silicon; the Maps numbers from a 32-core ARM64 Linux VM.
Absolute figures will differ on your hardware. The *ordering* and the *ratios* are the
portable part, and they held across both machines.
- Both Playwright tools pin driver `1.60.0`, so the browser engine is identical across all
three arms. The benchmark measures binding and runtime overhead, not browser-engine speed.
- The Maps run is a modest sample used to sanity-check behaviour on a real, network-bound page.
It is not a claim about doing this at very large volume.
## Reproduce it yourself
Prerequisites: Python 3.10+, and Rust (via rustup). Node is not needed — both Playwright tools
bundle their own driver.
```bash
# 1. Python arm + the Chromium browser
python3 -m venv py-test/venv
py-test/venv/bin/pip install playwright==1.60.0
py-test/venv/bin/playwright install chromium
# on Linux also: py-test/venv/bin/playwright install-deps chromium
# 2. Build the two Rust arms
(cd rust-test && cargo build --release)
(cd rust-cdp && cargo build --release)
# 3. Tell the chromiumoxide arm where the browser is
export CHROMIUM_BIN=$(find ~/.cache/ms-playwright ~/Library/Caches/ms-playwright \
-name 'chrome*shell*' -type f 2>/dev/null | head -1)
# 4. Local benchmark: start the fixture server, then run
py-test/venv/bin/python -m http.server 8099 --bind 127.0.0.1 --directory server &
python orchestrator.py --iters 100 --warmup 5 --out results
# 5. Real Google Maps benchmark
python run_maps.py --per-arm 100 --out results_maps
```
Results land as `report.json` (aggregated stats) and `raw_runs.jsonl` (every run) in the
output directory.
## Repo layout
```
orchestrator.py local benchmark harness (9 scenarios, all 3 tools)
run_maps.py real Google Maps capture harness
py-test/arm.py Python + Playwright arm
rust-test/ Rust + playwright-rs arm
rust-cdp/ Rust + chromiumoxide arm
server/ local HTML fixtures + correctness oracle
results/ sample aggregated results
```
## License
MIT. See [LICENSE](LICENSE).