Struct method access speed

Jarrod qwerty at ytre.wq
Wed Dec 26 18:02:09 PST 2007


> The one that surprises me is gdc. For DMD, you actually fill the
> vector twice in the first loop (once with zeroes, then a second time
> with values) and it runs about twice as long as the second loop which is
> normal. However, for gdc, I can't explain the large time for the first
> loop...
> 
> 		Jerome

I agreed with you so I tested it out. I removed the for loop in create:
void create() {
  ap = cast(T*)malloc(N * T.sizeof);
}

Results:
timbus at TiMBoX:~/Desktop$ dmd -O -release -inline what.d 
gcc what.o -o what -m32 -lphobos -lpthread -lm 
timbus at TiMBoX:~/Desktop$ ./what 
0.37
0.19

Seems opIndexAssign needs a bit of fine tuning.



More information about the Digitalmars-d mailing list