Finding large difference b/w execution time of c++ and D codes for same problem

Marco Leise Marco.Leise at gmx.de
Wed Feb 13 07:26:59 PST 2013


Am Wed, 13 Feb 2013 15:45:13 +0100
schrieb Joseph Rushton Wakeling <joseph.wakeling at webdrake.net>:

> On 02/13/2013 03:29 PM, Marco Leise wrote:
> > They are actual storage in memory, where every increase in
> > size hurts.
> 
> When I replaced with TReal, it sped things up for double.

Oh this gets even better... I only added double as last step
to that code, so I didn't notice this effect. Looks like we've
got:

- CPUs that are good at converting to double
- 64-bit, so the size of a double matches
- only 16 bytes of memory in total

With double struct fields the 'double' case gains 50% speed
for me, making it the overall fastest now (on LDC). I'd still
bet a dollar that with an array of values floats would
outperform doubles, when cache misses happen. (E.g. more or
less random memory access.)

-- 
Marco



More information about the Digitalmars-d-learn mailing list