Benchmarks
Three PHP extensions implement the same API using Zend C, phpz (Zig) and PHPX (C++). Each workload measures the time PHP spends calling the extension and handling its result.
All workloads
The lightning bolt marks the lowest median in each row. Times are medians in nanoseconds per operation. PHPZ / C is the median of the paired time ratios across rounds. A value below 1 means phpz took less time. The 95% confidence interval uses 5,000 bootstrap resamples of whole rounds.
| Workload | C | PHPZ (Zig) | PHPX (C++) | PHPZ / C (95% CI) |
|---|---|---|---|---|
| args/int | 16.26 | 15.08 | 91.38 | 0.935 [0.917, 0.947] |
| args/null | 14.36 | 13.99 | 92.34 | 0.970 [0.956, 0.991] |
| args/omitted | 14.78 | 13.18 | 82.30 | 0.889 [0.874, 0.901] |
| array/cow | 972.98 | 970.84 | 1064.12 | 0.996 [0.984, 1.007] |
| build/16 | 35.48 | 34.63 | 214.89 | 0.984 [0.970, 0.997] |
| build/1024 | 814.24 | 806.39 | 10799.14 | 1.003 [0.984, 1.011] |
| call | 5.26 | 5.90 | 10.62 | 1.123 [1.112, 1.132] |
| callback | 43.12 | 45.71 | 106.88 | 1.061 [1.054, 1.074] |
| lookup/hit | 19.15 | 20.02 | 69.61 | 1.038 [1.018, 1.059] |
| lookup/miss | 16.38 | 18.08 | 67.96 | 1.108 [1.093, 1.122] |
| method | 30.92 | 31.19 | 48.38 | 1.010 [0.998, 1.019] |
| pipeline | 2959.12 | 2911.12 | 6687.20 | 0.995 [0.978, 1.010] |
| sum/holes/1024 | 597.92 | 313.03 | 2184.72 | 0.521 [0.516, 0.529] |
| sum/map/16 | 14.56 | 13.87 | 74.08 | 0.951 [0.946, 0.957] |
| sum/map/1024 | 458.81 | 349.35 | 2554.79 | 0.765 [0.758, 0.771] |
| sum/mixed/1024 | 836.58 | 358.95 | 2574.77 | 0.430 [0.423, 0.432] |
| sum/packed/16 | 16.44 | 13.70 | 73.54 | 0.835 [0.828, 0.843] |
| sum/packed/1024 | 454.94 | 287.57 | 2534.34 | 0.633 [0.627, 0.637] |
Reproduce this run
benchmark/run.sh --check
benchmark/run.sh
Benchmark source and setup
Measurement details
- phpz
- 0.1.0
- Machine
- Intel Core i5-10600, logical CPU 4
- System
- Linux x86-64
- Runtime
- PHP 8.5.13 NTS, OPcache and JIT disabled
- Compilers
- GCC 16.2.1, Zig 0.17.0
- PHPX
- Swoole PHPX v2.9.8
- Runs
- 36 rounds per workload, 50 ms calibration target. Each sample ran in a fresh PHP process after warmup.