Bug #15443
closed
speedup of USER functions
Added by Sebastian Kurfuerst almost 19 years ago.
Updated about 16 years ago.
Description
Hi,
during the integration of CSC, Ernesto has observed that if the object is a USER cObject, it will be a lot slower than normal.
I have looked for anything which might relate to it... And it seems to be in tslib_content::callUserFunction
call_user_func and call_user_method are used here. In a note on PHP.net of call_user_func I found the following:
--snip--
You should avoid this function and use variable function calls instead!
The main reason for this is the fact that you will generate twice as many function calls as actually needed.
Thus, your server will encounter twice the load of function calls.
--snip--
Can anybody confirm this? If this is an issue, we should change it to use variable function calls. Are there any drawbacks with this?
Greets, Sebastian
(issue imported from #M2304)
Files
Speed comparison from PHP.net: http://www.php.net/call_user_func
"I benchmarked the comparison in speed between variable functions, call_user_func, and eval. My results are below:
Variable functions took 0.125958204269 seconds.
call_user_func took 0.485446929932 seconds.
eval took 2.78526711464 seconds."
What do you think? I think it's worth changing it to variable functions.
Greets, Sebastian
I tested the same on my server and the result is that
'eval' was nearly as fast as the variable function calls, call_user_func is the loser anyway, so I think it depends on either PHP version or system architecture.
And variable function calls have a slight 'hacky' reputation...
When you say "it's worth changing" you should take some benchmarks yourself on the tslib_content::callUserFunction parts first.
Just my 2 cents ;-)
I think it would be interesting if somebody would like to benchmark it, too.
I don't have time to change it right now.
Greets, Sebastian
Hey Dmitry, I know you like the profiler in Zend studio... so wouldn't that be a task for you? ;-)
The difference is minimal:
call_user_func: 0.75038
call_user_func_array: 0.76316
variable: 0.74727
This is per 10000 calls. I attach test script and also results by profiling with XDebug (use KCacheGrind for viewing).
Also available in: Atom
PDF