翻訳者から:それはすべてDに関するトピックから始まりました。
他の言語と比較したDのコンパイル速度を評価した後、Cを除いて、Dとほぼ同じかそれよりも速くネイティブコードにコンパイルする言語があるかどうか疑問に思いました。
その場合、おそらくLLVM以外のバックエンドを使用しているはずです。
ジェイはこれができると思いますが、まだリリースされていません。
言語とコンパイラのさまざまな組み合わせのコンパイル速度ベンチマーク。サポートされている言語:
ネイティブコードへのコンパイラ
- C(gcc、clang、cproc)、
- C ++(g ++およびclang ++)、
- D(dmd ldmd2、およびgdc)、
- Go(go and gccgo)、
- Swift(swiftc)、
- さび(rustc)、
- ジュリア(ジュリア)。
- エイダ(gnatgcc)、
- Zig (zig),
- V (v),
- Vox (vox),
- C3 (c3c),
-
- 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 , , — , .
対応するセクションからのリンクをたどると、ここにない他の言語との比較だけでなく、巨大なプログラムの構築に関して、コンパイラーの構築が4年間でどれだけ進んだかを見ることができます。