Fastest compiler aka compiler-benchmark

From the translator: it all started with a topic on D.



After evaluating the compilation speed of D compared to other languages, I was wondering if there is any language that compiles to native code almost as fast or faster than D, except for C?

If so, then most likely it should be using a backend other than LLVM.

I think Jai is capable of that, but he hasn't been released yet.

Compilation speed benchmarks for various combinations of languages ​​and compilers. Supported languages:



Compilers to native code





-





- Ubuntu ( 20.04) ./install-compilers-on-ubuntu-20.04.sh .







./benchmark \
    --function-count=$FUNCTION_COUNT \
    --function-depth=$FUNCTION_DEPTH \
    --run-count=5


$FUNCTION_COUNT $FUNCTION_DEPTH



./benchmark


.

,



./benchmark --languages=C++,D,Rust


generated , . Markdown, . , Time [us/#fn] , . (args.function_count * args.function_depth).



GCC Clang C++ ( ). D Rust, .





, , , ,



./benchmark --function-count=3 --function-depth=2 --run-count=5


C, generated/c/main.c



long add_long_n0_h0(long x) { return x + 15440; }
long add_long_n0(long x) { return x + add_long_n0_h0(x) + 95485; }

long add_long_n1_h0(long x) { return x + 37523; }
long add_long_n1(long x) { return x + add_long_n1_h0(x) + 92492; }

long add_long_n2_h0(long x) { return x + 39239; }
long add_long_n2(long x) { return x + add_long_n2_h0(x) + 12248; }

int main(__attribute__((unused)) int argc, __attribute__((unused)) char* argv[]) {
    long long_sum = 0;
    long_sum += add_long_n0(0);
    long_sum += add_long_n1(1);
    long_sum += add_long_n2(2);
    return long_sum;
}




. - . , .



, Go .





$LANG, , main.$LANG main_t.$LANG, main.$LANG, , ( main) . . Templated , .



.. , , . β€” .



( )



Vox, , . 3-4 , dmd. , Vox, , , , Windows , , .



D dmd cproc. , , cproc β€” .



GCC, Clang ( 8, 9, 10 ).



() C++ 3 , - gcc-8, 2.3 gcc-10. clang++-10 1.6. D (dmd) 2.5 . , , Rust 2-3 , - .



JIT- ( ) . function-count function-depth Julia β€” 5000. , .



OCaml ocamlopt , function-count function-depth 10000.





Intel Core i7-4710HQ CPU @ 2.50GHz Γ— 8 16 GB Ubuntu 20.04



./benchmark --function-count=200 --function-depth=450 --run-count=3


, Pypy 3



pypy3 ./benchmark --function-count=200 --function-depth=450 --run-count=3




. , , β€” , . β€” / . 4 .

. ( ), .







β€” 5746,1







  • C3
  • Subprocess
  • Fortran
  • Pony








, . D Phobos , , β€” , .



β€” , β€” , 12 D 230 Rust, .



Following the link from the corresponding section, you can see not only a comparison with other languages ​​that are absent here, but also how far compiler building has made in 4 years in terms of building huge programs.




All Articles