[TYPO3-core] RFC #16951: [Performance] Speed up makeInstance() by caching getClassName() results

Pierre Dudoret p.dudoret at groupe-belink.fr
Fri Feb 11 11:50:32 CET 2011


2011/2/10 Christian Kuhn <lolli at schwarzbu.ch>
> On 02/10/2011 11:06 AM, Pierre Dudoret wrote:
>> Check the attached patch :
>> - No more recursivity
>
> Recursions are quick, pushing registers to stack takes nanoseconds if at all. That's nothing from php point of view.
> Did you actually measure a performance gain or is your patch an assumption?

I didn't test it, but it even if pushing register is fast, not pushing
register should be faster.

>> - Only one call to class exists per iteration instead of 2
> Why? Your first 'if' only fails if there is no such class (-> error out -> exception -> no production code).
> Thus, the second class_exists() in while() is always called, so no reduction of class_exists() calls.
> Where is the difference to the recursive method? Did I get something wrong?

In fact, there's a reduction of call count sonly if there's a ux_. I
should have wrote :
"Only one call to class exists per iteration BUT FIRST instead of 2".


As you exited my curiosity, i did some tests (out of Typo3 context, on
a php 5.2, without any autoloader)
by calling 100000 times the 2 functions.

Without any ux :
- recursive version : 0.357 seconds
- iterative version : 0.344 seconds
(the difference is probably due to the trinary operator)

With only one ux (so 1 iteration / recursion) :
- recursive version : 0.843 seconds
- iterative version : 0.521 seconds

With 2 ux :
- recursive version : 1.364 seconds
- iterative version : 0.657 seconds

So I would agree if you argue that the average difference would be
"only" 4% less time in this function,
wich would represent something like 1 millisecond in a whole page
rendering. But why would we spit on
those 4% AND a cleaner version (from my point of view, of crouse).

Regards,
Popy


More information about the TYPO3-team-core mailing list