[fpc-devel] Generated code of constant parameters of double type
klenin at gmail.com
Mon Nov 17 04:10:31 CET 2008
On Mon, Nov 17, 2008 at 05:39, Florian Klaempfl <florian at freepascal.org> wrote:
> No, just look at the actual assignment:
> By const/reference it generates 5 instructions, by value only 4. The rest is
> entry code. If you've only one access, passing by reference might have an
> advantage, the more accesses you have, the better direct passing is.
This is true only if the code is compiled without optimization. At -O2 level,
the access code is indeed identical from performace POV.
> Just benchmark a loop ;)
I did, see attachment. On the random old PC it gives me:
By val = 1.47s
By ref = 0.72s
By increasing the value of NR constant, you can diminish speed difference,
but the by-ref case is always faster.
Anyway, for me the true reason for always using by-ref convention for
is semantic consistency and Delphi compatibility.
Alexander S. Klenin
Insight Experts Ltd.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 712 bytes
Desc: not available
More information about the fpc-devel