N-body bench

Stanislav Blinov stanislav.blinov at gmail.com
Thu Jan 30 12:01:23 PST 2014


On Thursday, 30 January 2014 at 18:43:02 UTC, bearophile wrote:

> It's a very silly problem for a statically typed language. The 
> D type system knows the static length of those arrays, but it 
> doesn't use such information.

I agree.


Unrolling everything except the loop in energy() seems to have 
squeezed the bits neede to outperform c++, at least on my machine 
:)

http://dpaste.dzfl.pl/45e98e476daf

(I'm sticking to atoi because my copy of ldc seems to have an 
issue in std.conv).

time ./nbody-cpp 50000000:
-0.169075164
-0.169059907
0:05.15 real, 5.14 user, 0.00 sys, 532 kb, 99% cpu

time ./nbody-ldc 50000000:
-0.169075164
-0.169059907
0:04.41 real, 4.40 user, 0.00 sys, 1308 kb, 99% cpu

time ./nbody-dmd 50000000:
-0.169075164
-0.169059907
0:15.39 real, 15.34 user, 0.00 sys, 1192 kb, 99% cpu



More information about the Digitalmars-d-learn mailing list