Project

General

Profile

Bug #15443 » userfunc.php

Administrator Admin, 2008-05-12 15:25

 
<?php

function work($param, $pObj) {
for ($i = 0; $i < 1000; $i++) {
$c = $i+1;
}
return $c;
}

function cuf() {
for ($i = 0; $i < 1000; $i++) {
call_user_func('work', 1, 2);
}
}

function cuf_a() {
for ($i = 0; $i < 1000; $i++) {
call_user_func_array('work', array(1, 2));
}
}

function cvar() {
for ($i = 0; $i < 1000; $i++) {
$var = 'work';
$var(1, 2);
}
}


$t0 = microtime(true);
cuf();
$t1 = microtime(true);
cuf_a();
$t2 = microtime(true);
cvar();
$t3 = microtime(true);

echo sprintf('%.5f %.5f %.5f%c', $t1 - $t0, $t2 - $t1, $t3 - $t2, chr(10));

?>
(1-1/3)