2017 © Pedro Peláez
 

library php-bench

Benchmark your application methods in a simple way

image

wdalmut/php-bench

Benchmark your application methods in a simple way

  • Saturday, October 24, 2015
  • by wdalmut
  • Repository
  • 1 Watchers
  • 6 Stars
  • 61 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Benchmark your class methods or functions

Build Status, (*1)

Just a simple way to benchmark your class methods or functions., (*2)

./vendor/bin/bench run tests/

or with different paths, (*3)

./vendor/bin/bench run tests/ benchs/

Declare a bench method

Just create a method in a class starting with the benchmark keyword or use a simple @benchmark annotation in your doc-block., (*4)

class MyClass
{
    ...

    public function benchmarkUsingTheMethodName($b)
    {
        for ($i=0; $i<$b->times(); $i++) {
            my_project_function("%s", "hello");
        }
    }

    /**
     * @benchmark
     */
    public function this_bench_instead_use_the_annotation($b) {
        for ($i=0; $i<$b->times(); $i++) {
            $myObj->slowMethod("stub");
        }
    }
}

The benchmark method receive an object b from outside that contains the number of iterations that your bench function should run., (*5)

PHPUnit integration

Just add a benchmark method in your testcases., (*6)

class MyTest extends \PHPUnit_Framework_TestCase
{
    // Executed only by php-bench
    public function benchmarkMyAppMethod($b)
    {
        for ($i<0; $i<$b->times(); $i++) {
            sprintf("%s", "hello");
        }
    }

    public function testMyAppMethod()
    {
        // ...
        $this->assertEquals(...);
    }
}

Install with composer

You can use composer in order to get this library locally, (*7)

{
    "require-dev": {
        "wdalmut/php-bench": "*"
    }
}

Inspired by Golang benchmark library, (*8)

The Versions

24/10 2015

dev-master

9999999-dev

Benchmark your application methods in a simple way

  Sources   Download

MIT

The Requires

 

phpunit testing benchmark bench

24/10 2015

0.1.2

0.1.2.0

Benchmark your application methods in a simple way

  Sources   Download

MIT

The Requires

 

phpunit testing benchmark bench

24/10 2015

0.1.1

0.1.1.0

Benchmark your application methods in a simple way

  Sources   Download

MIT

The Requires

 

phpunit testing benchmark bench

24/10 2015

0.1.0

0.1.0.0

Benchmark your application methods in a simple way

  Sources   Download

MIT

The Requires

 

phpunit testing benchmark bench