Project

General

Profile

Actions

Bug #15443

closed

speedup of USER functions

Added by Sebastian Kurfuerst almost 19 years ago. Updated about 16 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2006-01-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.0
PHP Version:
4
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

userfunc.php (583 Bytes) userfunc.php Administrator Admin, 2008-05-12 15:25
cachegrind.out.5788.bz2 (5.63 KB) cachegrind.out.5788.bz2 Administrator Admin, 2008-05-12 15:53
KCacheGrind_report.png (17.9 KB) KCacheGrind_report.png Administrator Admin, 2008-05-12 17:02
Actions #1

Updated by Sebastian Kurfuerst over 18 years ago

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

Actions #2

Updated by Wolfgang Klinger over 18 years ago

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 ;-)

Actions #3

Updated by Sebastian Kurfuerst over 18 years ago

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

Actions #4

Updated by Ingo Renner almost 17 years ago

Hey Dmitry, I know you like the profiler in Zend studio... so wouldn't that be a task for you? ;-)

Actions #5

Updated by Dmitry Dulepov over 16 years ago

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).

Actions

Also available in: Atom PDF