Trident Benchmarks
Per-function compiler overhead analysis: compiles real library modules
from std/, vm/, and os/, then compares instruction counts and
execution costs against hand-optimized TASM baselines.
Directory Structure
benches/
end_to_end.rs Criterion bench
harnesses/ Live execution programs (.tri + .inputs)
std/compiler/lexer.tri
std/compiler/lexer.inputs
std/trinity/inference.tri
...
references/ Rust ground truth
std/crypto/poseidon2.rs
std/nn/tensor.rs
...
baselines/triton/ Hand-optimized TASM (separate top-level dir)
std/crypto/poseidon2.tasm
vm/core/field.tasm
os/neptune/kernel.tasm
...
harnesses/—.trisource +.inputsfiles for live execution benchmarksreferences/— Rust programs that generate inputs and expected outputs (ground truth)baselines/triton/— hand-optimized TASM baselines (top-level, outsidebenches/)
How It Works
trident benchscansbaselines/triton/for.tasmfiles- Each baseline maps to a source module by path:
baselines/triton/std/crypto/auth.tasm->std/crypto/auth.tri - The source module is compiled through the full pipeline (resolve, parse, typecheck, TIR, optimize, lower) without linking
- Both compiled output and baseline are parsed into per-function instruction maps
- Functions are matched by label name and instruction counts compared
Metrics
| Column | Meaning |
|---|---|
| Tri | Compiler-generated instruction count |
| Hand | Hand-optimized baseline instruction count |
| Ratio | Tri / Hand (1.00x = compiler matches expert) |
Running
trident bench # from project root
trident bench baselines/triton/ # explicit directory
trident bench baselines/triton/std/ # subdirectory
Works from any subdirectory -- walks up to find baselines/.
Adding a Baseline
- Write the
.trimodule instd/,vm/, oros/(real library code) - Create the matching baseline path:
baselines/triton/std/crypto/newmod.tasm - Write hand-optimized TASM with
__funcname:labels matching the module's public functions - Run
trident benchto see the comparison
Baseline Format
// Hand-optimized TASM baseline: std.crypto.example
__function_name:
instruction1
instruction2
return
__another_function:
instruction1
return
Rules:
- Labels use
__funcname:format (matching compiler output) - Comments (
//) are not counted - Labels (ending with
:) are not counted haltis not counted- Blank lines are not counted
- Everything else is counted