Skip to content

Docs/Reference/Benchmarks

Benchmarks

Fid measured against Rust, Zig, C++ and Go on four programs, with every result the project has, losses included, and how to reproduce them.

~3 min read

On this page

Every result the project has, losses included. The source of these numbers is docs/benchmarks.md in the compiler repository; if a number is wrong, open an issue.

What is measured

Four programs, each written in Fid, Rust, Zig, C++ and Go, in the repository’s bench/ folder:

ProgramWhat it measures
fibRecursive calls: fib(40)
loopInteger arithmetic in a counted loop, 2 billion times
sieveA 20-million-entry array, written and read in loops
hashmapOne million string keys inserted, then looked up

Each program prints one number, and a language that prints a different number is marked wrong, not timed. Fid is measured two ways: native (fid emit, no C compiler) and through C (fid ccompile with zig cc). The others are built as their users ship them: rustc -C opt-level=3, Zig ReleaseFast, Clang -O2, go build. Times are wall-clock seconds for the whole process, best of three.

Results

Nov 15, 2026

A busy shared machine (AMD Ryzen 7, 8 cores, Windows 11), so read these as noisy. Native Fid was not measured that day: the working tree could not build natively, and the column is left out rather than filled from another day.

BenchmarkFid via CRustZigC++Go
fib1.070.660.680.660.96
hashmap0.871.82-1.482.01
loop4.953.943.245.054.05
sieve0.370.280.280.290.39

Through C, Fid is fastest on hashmap, 1.6 times the fastest on fib, 1.3 times on sieve and 1.5 times on loop. Zig has no hashmap program yet.

Nov 3, 2026

Windows 11 x64, one laptop, best of three.

BenchmarkFid nativeFid via CRustZigC++Go
fib1.370.920.590.640.610.96
hashmapover 60 s0.851.34-1.290.94
loop8.583.783.213.763.993.12
sieve0.800.550.260.290.260.30

Native output was two to three times slower than through C (the native backend had no optimizer then), and native hashmap was quadratic.

Nov 2, 2026

The earlier run on the same machine, kept because it differs: Rust’s loop took 5.36 s here and 3.21 s a day later, which shows how noisy one laptop is.

BenchmarkFid nativeFid via CRust
fib(40)1.340.810.53
loop, 2 billion7.593.535.36
sieve, 20M0.820.480.40
hashmap, 1M strings1.040.801.12

Known weak spots

  • fib is about 1.5 times Rust through C and over twice natively. Fid checks every addition for overflow; Rust’s release mode does not.
  • sieve was about twice the others on Nov 2–3 and 1.3 times on Nov 15.
  • Native output (fid emit) is slower than through C on every program measured.
  • Compile speed: the compiler compiles its own source to C in about 40 s (Nov 15). That is the widest gap to Go and Zig.

Not measured yet

The Benchmarks Game set, real workloads (JSON, regex, sorting), service benchmarks with the client on another machine, binary size and memory, Linux runs, and the spread across several runs.

Reproduce it

./bench/run.sh                    # every program, every language, best of 3
RUNS=5 ./bench/run.sh fib sieve   # some programs, best of 5

run.sh builds every program, checks that all languages print the same number, and prints a table with the toolchain versions. It needs Bash, zig 0.16, rustc and go.

Good to know: a corrected program for another language replaces ours, and a result that makes Fid look worse is as welcome as one that makes it look better.

Report an issue