This script generates long repetitive programs in various languages (statically typed ones that target native code) and measures the time taken to compile them.
Every program is roughly of the form:
main() {
var x = 0
{% n*2 times: %}
x = 2
print(i)
x = 3
print(i)
{% end %}
}
Compilers tested:
- C (Apple clang 12.0.0)
- D (dmd 2.095.0)
- LLVM IR (llc 12.0.0, release build with assertions)
- OCaml (ocamlopt 4.09.0)
- Nim (nim 1.4.2)
- Rust (rustc 1.48.0)
- V (v 0.2 f713597)
- Zig (zig 0.7.1)
Included are timings on my machine for selected values of n
. My tentative ranking of compilation speed on these benchmarks is something like C > V ≈ LLVM IR > Nim > OCaml > D > Rust > Zig
. Note that this is not representative of what most code looks like in practice, however.