从翻译者那里:一切都从D主题开始。
在评估了D与其他语言相比的编译速度之后,我想知道是否有任何一种语言可以编译到本机代码中,几乎比D快或快,除了C?
如果是这样,则很可能应该使用除LLVM之外的后端。
我认为Jai有能力做到这一点,但他尚未被释放。
适用于多种语言和编译器组合的编译速度基准测试。支持的语言:
本地代码编译器
- C(gcc,clang和cproc),
- C ++(g ++和clang ++),
- D(dmd ldmd2和gdc),
- 去(去和gccgo),
- 斯威夫特(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 , , — , .
通过相应部分的链接,您不仅可以看到与此处缺少的其他语言的比较,还可以看到在构建大型程序方面四年来编译器的开发取得了多大的进步。