Skip to content

Commit 2f386d9

Browse files
jqueguinerclaude
andcommitted
docs: publish Rust vs Python benchmark tables in READMEs
Add benchmark results (real-names infer ~4.6x, weighted replacement ~4.5x, parquet load ~3.9x) plus reproduce commands to README.md and rust/README.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 320e4d0 commit 2f386d9

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,31 @@ cargo test --features real-names # opt-in parquet ground truth
5757

5858
See [`rust/README.md`](rust/README.md).
5959

60+
## Benchmarks
61+
62+
Rust (release) vs Python, 1,000,000 operations each. The real-names rows run the
63+
**same algorithm** on both sides (apples-to-apples); "basic name gen" compares
64+
the Rust port against upstream faker's heavier code path, so treat it as
65+
indicative only.
66+
67+
| Task (1M ops) | Python | Rust (release) | Speedup |
68+
|---|---:|---:|---:|
69+
| `infer_gender` (real, 139 countries) | 2.79 M ops/s | 12.79 M ops/s | ~4.6× |
70+
| `first_name_like` (real, freq-weighted) | 0.84 M ops/s | 3.79 M ops/s | ~4.5× |
71+
| parquet bank load (1.43M rows, one-time) | 8.9 s | 2.3 s | ~3.9× |
72+
| basic name generation | 0.037 M ops/s | 11.90 M ops/s | ~320× \* |
73+
74+
\* Not identical logic — Rust port vs upstream faker `first_name`.
75+
76+
Reproduce:
77+
78+
```bash
79+
# Rust
80+
cd rust && cargo run --release --features real-names --example bench
81+
# Python
82+
PYTHONPATH=. python3 scripts/bench_naming.py
83+
```
84+
6085
## Data provenance
6186

6287
The name dataset was extracted from a PostgreSQL dump and normalized so

rust/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ f.first_name_real(Some("JP"), Gender::Female); // weighted female JP name
8787
- Pulls in `parquet` + `arrow` (only under this feature).
8888
- Dataset path overridable via `FAKER2_NAMES_PARQUET`.
8989

90+
### Benchmark
91+
92+
`cargo run --release --features real-names --example bench` (1M ops):
93+
94+
| Task | Rust (release) | Python |
95+
|---|---:|---:|
96+
| `infer_gender_real` | 12.79 M ops/s | 2.79 M ops/s |
97+
| `first_name_like_real` | 3.79 M ops/s | 0.84 M ops/s |
98+
| bank load (1.43M rows) | 2.3 s | 8.9 s |
99+
100+
~4–5× faster on identical logic. See top-level `README.md` for the full table.
101+
90102
## Grammatical number agreement
91103

92104
```rust

0 commit comments

Comments
 (0)