Trine benchmarks
Native Trine against C, Rust and Python, with overflow and bounds checks kept. Measured 2026-11-30 on Intel(R) Xeon(R) Processor @ 2.10GHz (2 cores), Trine f40f644.
1.04×
0.97×
22×
99.97%
Native code (bench/v1)
| benchmark | Trine | C | Rust | Python | Trine ÷ C (dashed line: equal) |
|---|---|---|---|---|---|
| fib recursive calls: fib(35) | 8 ms | 13 ms | 23 ms | 744 ms | |
| sieve array loop: primes up to 20M | 155 ms | 108 ms | 104 ms | 3436 ms | |
| trees allocation: binary trees, depth 16 | 286 ms | 478 ms | 483 ms | 1320 ms | |
| nbody floats + records updated in place: 5 bodies, 500k steps | 31 ms | 21 ms | 16 ms | 1806 ms | |
| spectral floats + calls: spectral norm, n = 1000 | 116 ms | 52 ms | 52 ms | 5701 ms | |
| strings text: build 300k CSV lines, split, parse | 73 ms | 32 ms | 47 ms | 319 ms | |
| matmul kernel: 512x512 Float matmul (Trine applies matmul.sched) | 79 ms | 239 ms | 201 ms | - |
Method
- Same output. Every program prints identical output in every language; the script refuses to time a benchmark whose outputs differ.
- Wall clock, best of 5 (Python: best of 3, or one run when a run takes over 10 s), including process startup, which is measured on its own with an empty program.
- Safety kept. Trine keeps overflow checks and every bounds check its verifier can't prove.
rustisrustc -O(no overflow checks),rust+checksadds-C overflow-checks=on,ciscc -O2, Python is CPython. Trine istrine build(-O2, no profile, no-march=native). - Realistic sizes, chosen so that each run takes tens to hundreds of milliseconds.
- Published whatever they show. The gaps are listed with their causes.
- Noise. This machine's timings move by up to ~30% between runs (the C and Rust columns move too). Changes to Trine are checked with deterministic instruction counts as well (
python3 tools/bench.py --instructions, the regression gate). - Reproduce:
python3 tools/benchmarks.py(needs cc, rustc and python3) measures all of it and writes this page,docs/BENCHMARKS.md,bench/numbers.jsonand the README's figures.
The bets
Perceus + borrow inference removes 100% of refcount overhead on 5 of 7 golden programs; the lowest is matmul at 95.7%. 99.97% of run-time bounds checks erased (166,728 of 166,779). Matmul n=512: 2.86 s with closures → 58 ms with a two-line schedule (naive Rust: 201 ms).
| program | refcount overhead removed |
|---|---|
| calc | 100.0% |
| hello | 100.0% |
| higher_order | 100.0% |
| matmul | 95.7% |
| primes | 100.0% |
| shapes | 100.0% |
| values | 99.8% |
| program | bounds checks erased |
|---|---|
| higher_order | 35 / 39 |
| json | 30,158 / 30,158 |
| matmul | 44 / 88 |
| primes | 27,295 / 27,295 |
| raytrace | 9,567 / 9,567 |
| server | 99,623 / 99,625 |
| shapes | 3 / 3 |
| values | 3 / 4 |
Running programs
trine run uses a cached native build when the program ran before (4 ms for json.tr, 25 ms on the VM), otherwise interprets immediately and switches to native mid-run once a background build lands (first run of fib(35): 234 ms instead of 4.66 s on the VM). The VM against CPython, fib(27): 90 ms on the VM vs 34 ms in CPython, both with startup.