Is D slow?

Honey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 9 09:21:22 PDT 2017


Hi guys,

I wrote a toy benchmark in C++ [1] and tried to literally 
translate it to D [2].

The results are quite disappointing. What seems particularly 
strange to me is that -boundscheck=off leads to a performance 
decrease.

Am I missing anything?

// $ clang++ -std=c++1z -O3 cmp-bench.cpp
// $ time ./a.out
// 501
//
// real 0m2.777s
// user 0m2.774s
// sys  0m0.004s
//
//
// $ clang++ --version
// clang version 4.0.0 (tags/RELEASE_400/final)
// Target: x86_64-unknown-linux-gnu
// Thread model: posix
// InstalledDir: /usr/bin

// $ ldc2 -O3 -release cmp-bench.d
// $ time ./cmp-bench
// 501
//
// real	0m5.257s
// user	0m5.224s
// sys	0m0.000s
//
//
// $ ldc2 -O3 -release -boundscheck=off cmp-bench.d
// $ time ./cmp-bench
// 501
//
// real	0m11.083s
// user	0m11.083s
// sys	0m0.000s
//
//
// $ ldc2 --version
// LDC - the LLVM D compiler (1.2.0):
//   based on DMD v2.072.2 and LLVM 4.0.0
//   built with DMD64 D Compiler v2.074.0
//   Default target: x86_64-unknown-linux-gnu
//   Host CPU: haswell

[1] C++ Insertion Sort - https://dpaste.dzfl.pl/74fdb92a0579
[2] D Insertion Sort   - https://dpaste.dzfl.pl/b97a1fca1546


More information about the Digitalmars-d-learn mailing list