← all benchmarks

Lazy Var Implementation Benchmarks - 2026-06-05

This records the performance benchmark of the compiler and generated code after implementing block-scoped "lazy" inline variable declarations.

Milestone Note

This benchmark verifies both compilation speed and the execution speed (runtime) of the compiler binaries when built via FPC vs. self-hosted compiler.

Subject

Environment

Results

1. Compiler Build Speed (hyperfine compiler build)

Workload FPC mean Self-hosted mean Ratio
Compile compiler source once 1.168 s ± 0.023 s 1.147 s ± 0.043 s 1.02x faster (Self-hosted)
Compile hello 20 times 793.1 ms ± 10.2 ms 45.3 ms ± 5.4 ms 17.49x faster (Self-hosted)

2. Compiler Runtime Speed (hyperfine execution runs)

Workload FPC-built mean Self-hosted mean Ratio
Compiling compiler source 491.2 ms ± 14.0 ms 1164.8 ms ± 63.8 ms 2.37x faster (FPC-built)
Compiling hello 20 times 272.4 ms ± 25.4 ms 51.6 ms ± 20.2 ms 5.28x faster (Self-hosted)

3. Output Executable Size

Output executable FPC Self-hosted
Compiler 1166704 bytes 928728 bytes
hello 191072 bytes 287 bytes

Interpretation

The self-hosted compiler compiles the small test program hello.pas significantly faster than FPC (17.49x faster). The compile times for compiling the compiler itself are very similar (FPC 1.168s vs Self-hosted 1.147s). In terms of runtime performance when compiling the heavy compiler codebase, the FPC-built binary is faster (2.37x faster) because FPC applies optimizations (-O2) when building the compiler, while the self-hosted compiler compiles directly to machine code without optimizations. However, compiling simple hello program is faster under the self-hosted compiler's runtime due to the zero-overhead/lightweight nature of its generated code.