I'd like to ask a question about call_user_func/_array performance and
the use of runtime variables to call functions and methods from the
PHP internals perspective.

Many people have blogged about how:-

    $callable = array($object, $bar);
    call_user_func_array($callable, $args);

is considerably slower than

    $object->$bar($args);

and there seem to be plenty benchmarks to back this up.

What is the official standpoint from the PHP developers and is there
are reason to use call_user_func/_array over using variables to
express the call when considering opcode caching?  What I mean for
example, is, when using $foo->$bar($args) at runtime, maybe this is
faster than call_user_func but maybe not if an opcode cache is
involved (e.g. maybe it cannot cache $foo).  I ask this because things
like __call() and __get() are also notoriously slow.

Also, would there be a reason for certain dynamic notations to be
slower than others (again with and without opcode caching incolved) -
a few examples below:

    $foo();
    $foo->$bar();
    $array[0]->$array[1];
    $foo::bar();
    $array[0]::$array[1]();

PHP has evolved a lot over the years so it would be nice to know what
the intention, pros and cons of these methodologies are from an
official internals point of view and if anything has been changed to
over time to make these methodologies more efficient.

Regards,

Drak

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to