Performance baseline (roadmap P1)
python3 tools/bench.py measures every benchmark, compares it with bench/baseline.json, and exits 1 on a confirmed slowdown of more than 10%. --save records a new baseline. Each figure is the fastest of 7 runs. Anything flagged is re-measured 21 times before it is reported, because single runs on this shared 2-core machine vary by more than 15%.
Baseline (2026-11-26, v0.6)
| benchmark | tree interpreter | IR VM (--vm --reuse --prove) | CPython 3 | VM vs CPython |
|---|---|---|---|---|
| fib(27) | 287.5 ms | 158.7 ms | 35.6 ms | 4.5× slower |
| primes (sieve to 10,000) | 20.2 ms | 35.6 ms | 18.1 ms | 2.0× slower |
| json (parse + print + 6 KB round trip) | 40.0 ms | 67.7 ms | — | — |
| raytrace (56×22) | 121.8 ms | 95.4 ms | — | — |
| server (515 requests) | 54.4 ms | 64.7 ms | — | — |
| fbip (tree rebuilt 11×) | 22.1 ms | 11.9 ms | — | — |
Times are whole-process wall time. They include parsing, type checking, and for the VM, ownership analysis and bounds verification.
Update: unboxing (#41)
| benchmark | interp | VM | native | CPython | Rust | native vs Rust |
|---|---|---|---|---|---|---|
| fib(27) | 286.2 ms | 156.0 ms | 2.3 ms | 34.0 ms | 2.3 ms | 1.0× |
| primes | 12.7 ms | 23.7 ms | 1.5 ms | 13.8 ms | 1.3 ms | 1.2× |
| json | 41.2 ms | 65.6 ms | 3.9 ms | — | — | — |
| raytrace | 133.2 ms | 82.7 ms | 1.7 ms | — | — | — |
| server | 54.3 ms | 61.6 ms | 3.4 ms | — | — | — |
| fbip | 22.5 ms | 11.3 ms | 1.7 ms | — | — | — |
Larger workloads: fib(32) runs in 12 ms vs 10 ms in Rust (1.2×) vs 236 ms in CPython. A sieve to 3,000,000 runs in 23 ms vs 20 ms in Rust (1.15×) vs 492 ms in CPython.
Update: native backend (#23)
tools/bench.py now also builds each benchmark natively (only execution is timed) and compiles Rust versions of fib and primes. On these short programs process startup (about 1 ms) is a large part of every number:
| benchmark | interp | VM | native | CPython | Rust |
|---|---|---|---|---|---|
| fib(27) | 283.2 ms | 172.6 ms | 3.0 ms | 33.9 ms | 1.8 ms |
| primes | 18.1 ms | 23.2 ms | 1.4 ms | 14.3 ms | 1.2 ms |
| json | 39.5 ms | 65.6 ms | 3.1 ms | — | — |
| raytrace | 121.5 ms | 84.6 ms | 3.1 ms | — | — |
| server | 53.4 ms | 61.0 ms | 2.8 ms | — | — |
| fbip | 22.7 ms | 12.1 ms | 1.8 ms | — | — |
On larger workloads, where startup doesn't hide anything: fib(32) runs in 20 ms native vs 10 ms in Rust vs 238 ms in CPython. A sieve to 3,000,000 runs in 118 ms vs 21 ms vs 483 ms. See docs/NATIVE.md for why the sieve gap is memory layout, and what fixes it.
Reading it honestly (v0.6 numbers, before the native backend)
- Trine is slower than CPython today, 2–4.5× on the comparable benchmarks. Both engines are unoptimized interpreters written for clarity and measurement, not speed.
- The VM is not always faster than the tree interpreter. On short programs (primes, json) its fixed costs dominate: lowering, ownership analysis, and running the bounds verifier.
- None of bets 1 and 2 shows up here yet. Erased refcounts and bounds checks become speed only in compiled code. The native backend (roadmap #23) is next, and these numbers are the bar it has to clear. The target (P3) is within 2× of Rust.