Constructor performance in dmd

Marco Leise Marco.Leise at gmx.de
Tue Dec 10 13:44:37 PST 2013


Am Tue, 10 Dec 2013 12:42:10 +0100
schrieb "FreeSlave" <freeslave93 at gmail.com>:

> Let's leave this zero and change scalar to float. Again, very 
> good performance. Now change from zero to T.init:
> 
> T[dim] _arr = T.init;
> 
> It becomes 5 times slower than zero version.
> 
> Also I should notice it looks like -O option does not help here.
> 
> ldc has pretty good results in all cases.

I would think that NaNs are explicitly set for each element,
while "all zeroes" uses a fast zerofill method (e.g.
memset(ptr, 0)).
No idea about the other cases. I think DMD is just not
checking for duplicate initializations and lacking some good
struct initialization or vector copy code gen.

-- 
Marco



More information about the Digitalmars-d-learn mailing list