note 68147 added to function.call-user-func
| From: | rlansky at webroot dot com | Date: | Fri, 14 Jul 2006 23:17:18 +0000 |
| Subject: | note 68147 added to function.call-user-func | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114798@lists.php.net to get a copy of this message | ||
Based on the previous posts, it appears that using call_user_func can be serveral times slower than
using variable substitution. I think these results are somewhat misleading.
I set up a similar test in which a static method of an object was called repeatedly in a loop. I got
similar results to those seen; when calling the method using call_user_func the execution was twice
that of calling the method directly. However, I then started adding some "meat" to the
method in question. In my case, I found that what was constant was not the percentage change, but
rather that there is a fixed cost to using call_user_func.
In my case, this fixed cost was 2 microseconds per call. When executing a method that performs no
operations, this is a large percentage of the execution time for that method. However, when using
this on a method that actually performs some work, the 2 microsecond cost is almost impossible to
measure.
It seems to me that if you want to use call_user_func to call a very fast executing method, and you
need to do this thousands of times, then you may want to reconsider. However, if you are using this
to call methods that are not executed thousands of times, the small fixed cost of using php
call_user_func is probably not an issue.
----
Server IP: 216.194.113.175
Probable Submitter: 216.17.231.24
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func.php
Edit -- http://master.php.net/note/edit/68147
Del: integrated -- http://master.php.net/note/delete/68147/integrated
Del: useless -- http://master.php.net/note/delete/68147/useless
Del: bad code -- http://master.php.net/note/delete/68147/bad+code
Del: spam -- http://master.php.net/note/delete/68147/spam
Del: non-english -- http://master.php.net/note/delete/68147/non-english
Del: in docs -- http://master.php.net/note/delete/68147/in+docs
Del: other reasons-- http://master.php.net/note/delete/68147
Reject -- http://master.php.net/note/reject/68147
Search -- http://master.php.net/manage/user-notes.php