Simplifies the process of creating and running benchmarks. The library self- calibrates so that the framework itself is not counted in the amount of time it takes to complete any of the tests.
use Phine\Bench\Suite;
use Phine\Bench\Test;
$suite = new Suite();
$suite[] = new Test(
function () {
usleep(500);
}
);
$suite['key'] = new Test(
function () {
sleep(1);
}
);
$suite['setup'] = Test::create(
function ($sleep, $usleep) {
sleep($sleep);
usleep($usleep);
}
)->setSetup(
function () {
return array(
rand(0, 2),
rand(500, 1000)
);
}
);
list($total, $times) = $suite->run();
echo $total, "\n"; // 3.003720998764
echo $times[0], "\n"; // 0.0012569427490234
echo $times['key'], "\n"; // 1.0002269744873
echo $times['setup'], "\n"; // 2.0022370815277
- PHP >= 5.3.3
- Phine Exception >= 1.0
Via Composer:
$ composer require "phine/bench=~1.0"
You can find the documentation in the docs/
directory.
This library is available under the MIT license.