Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

kherge-archive/lib-bench

Repository files navigation

Bench

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.

About

A PHP library for running timed tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages