[fpc-devel] static vs dynamic arrays

Peter Vreman peter at freepascal.org
Tue Apr 4 13:24:07 CEST 2006


> Something new at the end of message.
>
>> >> They are equally fast if you turn on register variables and if enough
>> >> free registers are available (e.g. on a PPC; possibly also on an x86
>> >> if you have a very simple loop and little or no variables used both
>> >> before and after the loop).
>> > It's wrong.
>>
>> bigmac:~/fpc/test jonas$ ppcppc69 -O3 tarr
>> Target OS: Darwin for PowerPC
>> Compiling tarr.pp
>> Assembling testdynstat
>> Linking tarr
>> 43 Lines compiled, 0.3 sec
>> bigmac:~/fpc/test jonas$ ./tarr
>> Enter dyn array len (1-1000000):1000000
>> Total:4789ms
>> Total:4809ms
>> bigmac:~/fpc/test jonas$ ./tarr
>> Enter dyn array len (1-1000000):1000000
>> Total:4897ms
>> Total:4787ms
>
> Wow!
> I'm glad for PowerPC, but anyhow: (formatted)
> 3954   4234
> 4000   4266
> 3938   4234
> 3890   4281
> 3907   4218
> I repeat, celeron 2.4 GHz, winxpsp2.
>
> In real program registers should be used more efficiently, especially when
> dealing with SEVERAL arrays, than for support of ONE dynamical array.
> So, the circumstances described by you can only be reached in special
> cases.
>
> I don't mean to blame/flame or something, I just ask (in developers' mail
> list):
>
> What can I do to speed up dynamical arrays?
>
> What can I do to speed up static arrays?

If you really want to speed up both cases you need to use pointers and
increase the pointer value in each iteration. This saves the indexing in
every iteration.

Also place the code in small procedures so the register allocator has less
conflicts for assigning registers to variables.






More information about the fpc-devel mailing list