Re: D code optimization

2016-09-22 Thread Guillaume Piolat via Digitalmars-d-learn
Hi, Interesting question, so I took your examples and made them do the same thing with regards to allocation (using malloc instead of new in both languages). I removed the stopwatch to use "time" instead. Now the programs should do the very same thing. Will they be as fast too? D code:

Re: D code optimization

2016-09-22 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 22 September 2016 at 16:09:49 UTC, Sandu wrote: It is often being claimed that D is at least as fast as C++. Now, I am fairly new to D. But, here is an example where I want to see how can this be made possible. So far my C++ code compiles in ~850 ms. While my D code runs in about

Re: D code optimization

2016-09-22 Thread thedeemon via Digitalmars-d-learn
On Thursday, 22 September 2016 at 16:09:49 UTC, Sandu wrote: const int n = 252; double[] call = new double[n+1]; ... //delete call; // since D is has a garbage collector, explicit deallocation of arrays is not necessary. If you care about speed, better

Re: D code optimization

2016-09-22 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 22, 2016 at 04:09:49PM +, Sandu via Digitalmars-d-learn wrote: > It is often being claimed that D is at least as fast as C++. > Now, I am fairly new to D. But, here is an example where I want to see > how can this be made possible. > > So far my C++ code compiles in ~850 ms. >

Re: D code optimization

2016-09-22 Thread Brad Anderson via Digitalmars-d-learn
On Thursday, 22 September 2016 at 16:09:49 UTC, Sandu wrote: It is often being claimed that D is at least as fast as C++. Now, I am fairly new to D. But, here is an example where I want to see how can this be made possible. So far my C++ code compiles in ~850 ms. While my D code runs in about

Re: D code optimization

2016-09-22 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 22 September 2016 at 16:09:49 UTC, Sandu wrote: It is often being claimed that D is at least as fast as C++. Now, I am fairly new to D. But, here is an example where I want to see how can this be made possible. So far my C++ code compiles in ~850 ms. I assume you meant that it

D code optimization

2016-09-22 Thread Sandu via Digitalmars-d-learn
It is often being claimed that D is at least as fast as C++. Now, I am fairly new to D. But, here is an example where I want to see how can this be made possible. So far my C++ code compiles in ~850 ms. While my D code runs in about 2.1 seconds. The code translated in D looks as follows