Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
On Sunday, 13 August 2017 at 09:08:14 UTC, Petar Kirov [ZombineDev] wrote: There's one especially interesting result: This instantiation: sum_subranges(std.range.iota!(int, int).iota(int, int).Result, uint) of the following function: auto sum_subranges(T)(T input, uint range) { import

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:33:53 UTC, Petar Kirov [ZombineDev] wrote: With Daniel's latest version ( http://forum.dlang.org/post/mailman.5963.1502612885.31550.digitalmars-d-le...@puremagic.com ) $ ldc2 -O3 --release sum_subranges2.d $ ./sum_subranges2 210 ms, 838 μs, and 8 hnsecs 5000

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
Gives me 5 μs and 2 hnsecs 5000 3 secs, 228 ms, 837 μs, and 4 hnsecs 5000 And you've compiled it with? Btw. clang for c++ version works worse than gcc (for this case [112ms vs 180ms]).

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
On Sunday, 13 August 2017 at 08:00:53 UTC, Daniel Kozak wrote: my second version on ldc takes 380ms and c++ version on same compiler (clang), takes 350ms, so it seems to be almost same Ok, on ideone (ldc 1.1.0) it timeouts, on dpaste (ldc 0.12.0) it gets killed. What version are you using?

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread amfvcg via Digitalmars-d-learn
On Sunday, 13 August 2017 at 07:30:32 UTC, Daniel Kozak wrote: Here is more D idiomatic way: import std.stdio : writeln; import std.algorithm.comparison: min; import std.algorithm.iteration: sum; import core.time: MonoTime, Duration; auto sum_subranges(T)(T input, uint range) { import std.

D outperformed by C++, what am I doing wrong?

2017-08-12 Thread amfvcg via Digitalmars-d-learn
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 mach