Benchmarks
Benchmarks were run on synthetic JSON payloads in Docker (
php:8.3-cli-bookworm). Results depend on hardware, payload size, PHP version, and runtime environment. These figures are project-level reference numbers, not universal guarantees.
Run benchmarks locally:
bash
make benchmark
# custom run: iterations, medium payload items, max capacity items
make benchmark BENCH_ITERATIONS=1000 BENCH_ITEMS=500 BENCH_CAPACITY=200000Core operation comparisons
| Operation | Implementation | Ops/sec |
|---|---|---|
| Diff | Native PHP | ~170 |
| Diff | JsonFast | ~570 |
| Schema validation | opis/json-schema | ~100 |
| Schema validation | justinrainbow/json-schema | ~50 |
| Schema validation | JsonFast | ~920 |
JsonFast diff is roughly 3.3× faster than the native PHP helper in this benchmark. Schema validation is roughly 9× faster than Opis and 18× faster than JustinRainbow on the medium test document.
Plain English: diff and schema checks that used to mean separate PHP helpers or Composer libraries can run in one native call with substantially higher throughput.
Repair / merge / diff throughput
Measured on a ~32 MB broken/repairable JSON payload (200k items):
| Operation | Throughput |
|---|---|
| Repair | ~33 MB/sec |
| Merge | ~46 MB/sec |
| Diff | ~38 MB/sec |
Large JSON scaling
Capacity benchmark from 1k → 200k items (mean time, ms):
| Items | Repair | Merge | Diff |
|---|---|---|---|
| 1,000 | ~5 | ~2 | ~3 |
| 50,000 | ~250 | ~160 | ~210 |
| 100,000 | ~590 | ~320 | ~420 |
| 200,000 | ~1,060 | ~700 | ~850 |
All three operations scale roughly linearly with document size in this test.
What is compared
| Category | Compared against |
|---|---|
| Repair | JsonFast throughput (files/sec, MB/sec) |
| Encode / beautify / minify | json_encode() |
| Path access | json_decode() + manual traversal |
| Merge / diff | Native PHP helpers |
| Schema validation | opis/json-schema, justinrainbow/json-schema |
Metrics glossary
| Metric | Description |
|---|---|
| Ops/sec | Operations completed per second |
| Mean / P95 | Average and 95th percentile latency (ms) |
| Files/sec | Repair throughput by document count |
| MB/sec | Repair throughput by input payload size |
| Peak memory | Peak allocated memory during benchmark |
| Large JSON capacity | Scaling test from 1k → 200k nested records |
Custom benchmark run:
bash
php -d extension=target/release/libphp_jsonfast.so \
benchmarks/benchmark.php [iterations] [medium_items] [max_capacity_items]


