Compilation speed benchmark

C5.2s gcc test.c
C++1m 25s g++ test.cpp
Zig10.1s zig build-exe test.zig
Nim45s nim c test.nim
RustStopped after 30 minutesrustc
SwiftStopped after 30 minutes swiftc test.swift
DSegfault after 6 minutes dmd test.d
V0.6s v test.v

I wrote a small program that generates 400 000 lines of code in several languages to benchmark their compilation speed.

All compilers (except Go) don't do optimization in this benchmark.

update Turns out generating one function with 400k lines of code is a bad idea :) Go and D segfault, Java simply refuses to compile. I'll modify the test soon.

You can read the code of the generator here.

It's a bit silly, all it does is generate the following pair of statements 200 000 times:

a = 1 

a = 2 

I'm aware that in no way does this represent real code, but it can give a general picture, and all compilers face the same challenge.

Rust and Swift took too long to compile 400k lines, so I tried smaller numbers:

# linesRustSwift D
2k3.4s 0.8s
4k9.0s 1.0s
8k30.8s 2.3s
20k3m 52s 11.8s 4.7s
100k- 5m 57s segfault