Beispiel #1
0
function report($name, $time)
{
    static $last = null;
    printf("%-12s: %.8fms", $name, $time);
    if (null !== $last) {
        printf(", %.1f%%", ($time - $last) / $last * 100);
    }
    echo PHP_EOL;
    $last = $time;
}
// fixtures
$a = str_repeat('a', 2 << 8);
class O
{
    public function strcmp($a)
    {
        strcmp($a, $a);
    }
}
// do it
report('direct call', clock(function () use($a) {
    strcmp($a, $a);
}));
report('object call', clock(function () use($a) {
    $o = new O();
    $o->strcmp($a);
}));
report('voodoo call', clock(function () use($a) {
    $o = unserialize('O:1:"O":0:{}');
    $o->strcmp($a);
}));