Пример #1
0
<?php

require __DIR__ . '/../vendor/autoload.php';
function calculate()
{
    sleep(1);
    return 1;
}
bench\invoke('calculate');
bench\invoke('calculate');
foreach (bench\formatTimes(bench\collector()) as $time) {
    echo $time, PHP_EOL;
}
Пример #2
0
    }
}
bench\invoke('test1Baseline');
bench\invoke('test1ClosureAccess');
echo 'Testing public method access as property', PHP_EOL;
foreach (bench\formatTimes(bench\collector()) as $time) {
    echo $time, PHP_EOL;
}
function test2Baseline()
{
    $obj = new A();
    for ($i = 0; $i < TIMES; $i++) {
        assert($obj->mul(10, 10) === 100);
    }
}
function test2ClosureAccess()
{
    $obj = new A();
    $obj->mul1 = function ($a, $b) {
        return $a * $b;
    };
    for ($i = 0; $i < TIMES; $i++) {
        assert($obj->mul1(10, 10) === 100);
    }
}
bench\invoke('test2Baseline');
bench\invoke('test2ClosureAccess');
echo 'Testing set property call as public method', PHP_EOL;
foreach (bench\formatTimes(bench\collector()) as $time) {
    echo $time, PHP_EOL;
}