D outperformed by C++, what am I doing wrong?
data pulverizer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Aug 17 09:19:32 PDT 2017
On Sunday, 13 August 2017 at 06:09:39 UTC, amfvcg wrote:
> Hi all,
> I'm solving below task:
>
> given container T and value R return sum of R-ranges over T. An
> example:
> input : T=[1,1,1] R=2
> output : [2, 1]
>
> input : T=[1,2,3] R=1
> output : [1,2,3]
> (see dlang unittests for more examples)
>
>
> Below c++ code compiled with g++-5.4.0 -O2 -std=c++14 runs on
> my machine in 656 836 us.
> Below D code compiled with dmd v2.067.1 -O runs on my machine
> in ~ 14.5 sec.
>
> Each language has it's own "way of programming", and as I'm a
> beginner in D - probably I'm running through bushes instead of
> highway. Therefore I'd like to ask you, experienced dlang devs,
> to shed some light on "how to do it dlang-way".
>
> ...
>
From time to time the forum gets questions like these. It would
be nice it we had blog articles concerning high performance
programming in D, a kind of best practice approach, everything
from programming idioms, to compilers, and compiler flags.
More information about the Digitalmars-d-learn
mailing list