Benchmark
Two scripts, one rule: measure schema.parse(input) on a fixed input, report ms and ops/s, nothing else.
Scripts
| Script | Command | What it does |
|---|---|---|
benchmark/run.mjs | npm run bench | Parses 6 valdix schemas 50,000 times each. No dependency. |
benchmark/compare.mjs | npm run bench:compare | Parses 5 equivalent valdix/zod pairs 100,000 times each. Requires zod@3. |
Method
- Build first:
npm run build. Both scripts import../dist/index.js. - Warmup: 1,000 parses per schema. V8 compiles the hot path so the loop measures steady state, not first-call cost.
- Time with
performance.now()around a tightforloop. No async, no I/O inside. - ops/s is iterations divided by elapsed seconds.
Measured results
Machine: AMD Ryzen 5 6600H (12 threads), 16 GB RAM, Arch Linux kernel 6.18.38-1-lts, Node v24.15.0 x64. Valdix 0.6.0, averaged across 5 runs on 2026-09-14:
| case | avg ops/s | run 1 | run 2 | run 3 | run 4 | run 5 |
|---|---|---|---|---|---|---|
| string | 4.43M | 3.64M | 4.31M | 3.45M | 6.33M | 4.44M |
| 3.66M | 3.16M | 4.75M | 2.88M | 4.36M | 3.14M | |
| minLen | 5.52M | 6.47M | 5.04M | 4.85M | 5.56M | 5.70M |
| number | 5.12M | 5.29M | 4.72M | 4.63M | 6.86M | 4.10M |
| obj | 561k | 512k | 703k | 509k | 564k | 519k |
| array | 2.84M | 2.95M | 3.04M | 2.17M | 2.98M | 3.04M |
Per-run spread is wide (CPU frequency scaling on a laptop). Use the average, not a single run.
Against Zod
Same machine, Zod 3.25.76, 100,000 iterations per case, averaged across 5 runs. Valdix leads on email, numbers, objects, and arrays; plain strings are tied. Throughput still flips by machine and Zod version, so re-run on your hardware before repeating a speed claim.
| case | Valdix avg | Zod avg | result here |
|---|---|---|---|
| string | 6.06M | 6.21M | about tied |
| 4.33M | 3.16M | Valdix about 1.4x faster | |
| number | 7.75M | 5.48M | Valdix about 1.4x faster |
| object | 1.28M | 1.04M | Valdix about 1.2x faster |
| array | 4.27M | 1.48M | Valdix about 2.9x faster |
Reproduce
cd /tmp && mkdir bench && cd bench && npm init -y && npm i zod@3
ln -s /path/to/valdix/dist ./valdix
for i in 1 2 3 4 5; do node /path/to/valdix/benchmark/compare.mjs; doneAverage the 5 runs per case on an idle machine. Record CPU, Node version, valdix version, zod version, iteration count, and run count. Numbers from different machines are not comparable.
Limits
These scripts do not measure validation failure paths, async refinements, bundle size, memory use, or type inference quality. A 10-20% gap is noise. A 2x gap is real.