<?php
class A0 {
function foo($a, $b) {
$a + $b;
}
}
class A1 {
function foo($a, $b) {
$a + $b;
}
}
class A2 {
function foo($a, $b) {
$a + $b;
}
}
class A3 {
function foo($a, $b) {
$a + $b;
}
}
class A4 {
function foo($a, $b) {
$a + $b;
}
}
function row($name, $t) {
printf("%-40s %8s x 10 µs\n", $name, number_format((microtime(true)-$t)*1e5, 2));
}
$max = 5*1e1;
$objects = array(new A0, new A1, new A2, new A3, new A4, new A5) ;
$t = microtime (true);
for ($j=0; $j<5; $j++) {
for ($i=0; $i<$max; $i++) {
$objects[$j]->foo(1, 'foo');
}
}
row($max.' x A::foo', $t);
$t = microtime (true);
for ($j=0; $j<5; $j++) {
for ($i=0; $i<$max; $i++) {
call_user_func_array(array($objects[$j], 'foo'), array(1, 'foo'));
}
}
row($max.' x call_user_func_array', $t);
$t = microtime (true);
for ($j=0; $j<5; $j++) {
$ref = new ReflectionMethod($objects[$j], 'foo');
for ($i=0; $i<$max; $i++) {
$ref->invokeArgs($objects[$j], array(1, 'foo'));
}
}
row($max.' x ReflectionMethod::invokeArgs', $t);
- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0
- Fatal error: Uncaught Error: Class 'A5' not found in /in/easT9:37
Stack trace:
#0 {main}
thrown in /in/easT9 on line 37
Process exited with code 255. - Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.21
- Fatal error: Class 'A5' not found in /in/easT9 on line 37
Process exited with code 255. - Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
- Fatal error: Cannot instantiate non-existent class: a5 in /in/easT9 on line 37
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Fatal error: Cannot instantiate non-existent class: a5 in /in/easT9 on line 37
preferences:
156.37 ms | 401 KiB | 205 Q