Matrix Multiplication benchmark

RommelVR daniel350 at bigpond.com
Thu Aug 16 06:18:19 PDT 2012


On Thursday, 16 August 2012 at 13:15:41 UTC, Matthias Pleh wrote:
> I've created a simple 4x4 Matrix struct and have made some 
> tests, with surprising results. (although I've heard from 
> similar results in c++)
>
> struct mat4 {
>   float[4][4] m;
>   mat4 opMul(in mat4 _m);
> }
> mat4 mul(in mat4 m1, in mat4 m2);
>
>
> I've tested this 2 multiplication functions (overloaded and 
> free).
>
> Result (100_000 times, windows7 64bit, 32bit build):
>
> DMD: (dmd -O -inline -release)
> opMul:   20 msecs
> mul  : 1355 msecs
>
> GDC: (gdc -m32 -O3 -frelease)
> opMul:   10 msecs
> mul  : 1481 msecs
>
>
> Why this huge difference in performance?

See 
http://stackoverflow.com/questions/5142366/how-fast-is-d-compared-to-c.
Its not current, but it has some hints at what to look at.

I suggest changing 'in' to 'const ref' for a real boost; though 
the semantic difference between the two isn't exactly clear to me 
in the documentation.


More information about the Digitalmars-d-learn mailing list