I didn't make any suppositions.  I wrote two very simple benchmarking
scripts and timed how long they took, as an attempt to measure the
overhead of calling userland function aliases.  You're welcome to come
to whatever conclusions you want to based on this data.


On Sunday, September 9, 2001, at 12:43 PM, Cristopher Daniluk wrote:

<excerpt>Let's just make the supposition for a second that you're
right, that the

difference between calling a userspace function over an internal
function is

going to create phenomenal decreases in overall execution time. The

implication I believe you give is that over an amortized amount of
time,

execution speed between calling a userland function and internal
function

will be approximately 2x. 

</excerpt>

Try the example I listed with preg_match.  Clearly here one would not
expect that the execution speed is twice as long, as (at least
intuitively) preg_match does much more woirk than the userland alias.


<excerpt>This is just mind boggling! Sure, there's roughly

twice the work to call a user function wrapper compared to calling the

internal. There's also the loss in parsing. 

</excerpt>

The parsing overhead is amortized over a million executions of the
code block.


<excerpt>However, do not make the fatal

mistake of assuming that twice the cost of an operation translates to
twice

the cost of a process, or for that matter, even a negligible cost
increase.

</excerpt>


Why not?  It took twice as long to run.  To me that's a cost.  If I
was writing a bit of code which did an enormous number of executions
of simple userland functions, I would care about this.  If  I'm
calling _() or some other function 10 times on a page, then you;re
right, I won't care, but if I _do_ for whatever reasoncall a function
repeatedly, then it _can_ make a difference.  

<color><param>0000,0000,DEB7</param>

</color><excerpt>PHP would not, and I can't make this clear enough,
would NOT be a viable

option in the market if the performance loss in real world scenarios
from

simply entering into a function was that great. 

</excerpt>

What does this have to do with anything?  The market viability of php
implies nothing about the execution speed of function calls (though
the latter may be true.)


<excerpt>I'd venture (these are

SWAGs) to say that a single call to preg_replace does over 500x more
machine

instructions than calling a userland function. </excerpt>

<excerpt>I bet the gettext call

itself, which is the focal point of this discussion, does 50x more
machine

instructions, than the function call that's wrapping it. If you look
at it

on a microcosmic sense, there is a clear and real difference, but when
you

analyze on a macro level, you clearly can't argue there is a
performance

loss worth caring about. It's just childish and foolish and arguing it
makes

you look truly foolish. If you don't believe that, imagine for a tenth
of a

second that you're right, and think about the implications.

</excerpt>

Thinking about the ramifications of me being right shouldn't make me
analytically look at the cost of things?  Whatever.  Fortunately my
world view is gruonded enough that I think I can survive the
implications of userland function calls having a significant cost. 
Instead of sticking my head in the sand, I would rather use this
knowledge productively.  To me means when analyzing code efficiency
that one should realize that repeated call to userland functions have
an intrinsic cost in addtiion to the work done inside a function. 


