Benchmarks
The ten hot-path operations eth.zig tracks release over release, and how they are measured.
eth.zig benchmarks itself against its own previous releases. The suite is the ten operations that dominate a trading bot, liquidator or searcher hot loop.
| Benchmark | What it measures |
|---|---|
keccak256_32b | selector, storage-slot and mapping-key hashing |
keccak256_1kb | calldata- and transaction-sized hashing |
secp256k1_sign | signing a transaction hash |
secp256k1_recover | recovering a sender from a signature |
tx_hash_eip1559 | RLP-encoding an EIP-1559 transaction and hashing it |
abi_encode_transfer | encoding transfer(address,uint256) calldata |
abi_decode_dynamic | decoding (string,bytes) return data |
u256_mulDiv | full-precision a*b/c with a 512-bit intermediate |
u256_uniswapv4_swap | one exact-in swap-step price update |
dex_decode_universal_router | decoding a real 4-command Universal Router execute |
Latest results
Apple M4, 2026-10-10, fastest of 7 interleaved runs. Baseline: v0.9.2 on Zig 0.16.0.
| Benchmark | v0.9.2 (Zig 0.16) | v0.10.1 (Zig 0.17) | change |
|---|---|---|---|
keccak256_32b | 136.66 ns | 136.55 ns | -0.1% |
keccak256_1kb | 1043.85 ns | 1047.39 ns | +0.3% |
secp256k1_sign | 11421.14 ns | 11390.99 ns | -0.3% |
secp256k1_recover | 15159.87 ns | 15158.16 ns | 0.0% |
tx_hash_eip1559 | 142.99 ns | 143.49 ns | +0.3% |
abi_encode_transfer | 18.77 ns | 18.74 ns | -0.2% |
abi_decode_dynamic | 15.77 ns | 16.95 ns | +7.5% |
u256_mulDiv | 12.79 ns | 13.00 ns | +1.6% |
u256_uniswapv4_swap | 24.09 ns | 21.94 ns | -8.9% |
dex_decode_universal_router | (new) | 154.04 ns |
Running
zig build bench # all ten
zig build bench -- --filter keccak # a subset
zig build bench -- --save results.json # save a run
zig build bench -- --baseline results.json # compare with a saved runMeasurement
Each benchmark warms up for 200 ms, then reports the median ns/op over 31 batches of about 10 ms, with the minimum and median absolute deviation alongside. Inputs are read through an optimizer barrier on every call so nothing is constant-folded. To compare two versions, build both with zig build bench-install --prefix DIR and interleave them with python3 bench/ab.py OLD NEW, which keeps each benchmark's fastest run so interference from the rest of the machine cancels out. Full details are in bench/README.md.