General performance tips

sarn via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 23 14:51:23 PST 2017


On Monday, 23 January 2017 at 12:13:30 UTC, albert-j wrote:
> Well it is actually ODE solver from Numerical recipes 
> (originally in C++) that I am trying to do in D. Code 
> translation seems very straightforward. Maybe there's someone 
> around who has done that already? There's not much object 
> creation going on there, mostly loops over arrays, so I assume 
> GC is not an issue.

It really is hard without seeing the code.  When you said "from 
Java", my first thought was that you'd want to convert a lot of 
classes to structs, but you say there's not much object creation 
going on.

"mostly loops over arrays" makes me think of bounds checking.  
Try benchmarking after compiling with -boundscheck=off to see if 
this is responsible for your speed difference.

By the way, the original C++ code is probably closer to good D 
code than the Java code.

If you really want fast numerical D code, take a look at Mir and 
ndslice.


More information about the Digitalmars-d-learn mailing list