phine/bench

This package is abandoned and no longer maintained. No replacement package was suggested.

A PHP library for running timed tests.

1.2.0 2013-09-17 18:43 UTC

This package is not auto-updated.

Last update: 2021-12-07 01:40:49 UTC


README

Build Status Coverage Status Latest Stable Version Total Downloads

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.

Usage

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

Requirement

Installation

Via Composer:

$ composer require "phine/bench=~1.0"

Documentation

You can find the documentation in the docs/ directory.

License

This library is available under the MIT license.