Skip to content

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=200000

Core operation comparisons

Key JsonFast benchmark comparisons

OperationImplementationOps/sec
DiffNative PHP~170
DiffJsonFast~570
Schema validationopis/json-schema~100
Schema validationjustinrainbow/json-schema~50
Schema validationJsonFast~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

JsonFast throughput at 32MB JSON dataset

Measured on a ~32 MB broken/repairable JSON payload (200k items):

OperationThroughput
Repair~33 MB/sec
Merge~46 MB/sec
Diff~38 MB/sec

Large JSON scaling

Large JSON scaling benchmark

Capacity benchmark from 1k → 200k items (mean time, ms):

ItemsRepairMergeDiff
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

CategoryCompared against
RepairJsonFast throughput (files/sec, MB/sec)
Encode / beautify / minifyjson_encode()
Path accessjson_decode() + manual traversal
Merge / diffNative PHP helpers
Schema validationopis/json-schema, justinrainbow/json-schema

Metrics glossary

MetricDescription
Ops/secOperations completed per second
Mean / P95Average and 95th percentile latency (ms)
Files/secRepair throughput by document count
MB/secRepair throughput by input payload size
Peak memoryPeak allocated memory during benchmark
Large JSON capacityScaling 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]

Native tools, weird experiments, and practical performance work.