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.
vs C (geometric mean)1.04×
vs Rust (geometric mean)0.97×
faster than CPython22×
bounds checks erased99.97%

Native code (bench/v1)

benchmarkTrineCRustPythonTrine ÷ C (dashed line: equal)
fib
recursive calls: fib(35)
8 ms13 ms23 ms744 ms
0.61×
sieve
array loop: primes up to 20M
155 ms108 ms104 ms3436 ms
1.43×
trees
allocation: binary trees, depth 16
286 ms478 ms483 ms1320 ms
0.60×
nbody
floats + records updated in place: 5 bodies, 500k steps
31 ms21 ms16 ms1806 ms
1.48×
spectral
floats + calls: spectral norm, n = 1000
116 ms52 ms52 ms5701 ms
2.24×
strings
text: build 300k CSV lines, split, parse
73 ms32 ms47 ms319 ms
2.30×
matmul
kernel: 512x512 Float matmul (Trine applies matmul.sched)
79 ms239 ms201 ms-
0.33×

Startup (empty program): Trine 1 ms, C 1 ms, Rust 1 ms, Python 10 ms. Rust with overflow checks, compile times and the causes of each gap: docs/BENCHMARKS.md.

Method

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).

programrefcount overhead removed
calc100.0%
hello100.0%
higher_order100.0%
matmul95.7%
primes100.0%
shapes100.0%
values99.8%
programbounds checks erased
higher_order35 / 39
json30,158 / 30,158
matmul44 / 88
primes27,295 / 27,295
raytrace9,567 / 9,567
server99,623 / 99,625
shapes3 / 3
values3 / 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.

Generated by python3 tools/benchmarks.py · Linux 6.18.44-fc-v1045 · cc (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0 · rustc 1.97.0 (2d8144b78 2026-07-07) · Python 3.13.18