PHP code example of wdalmut / php-bench

1. Go to this page and download the library: Download wdalmut/php-bench library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wdalmut / php-bench example snippets


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");
        }
    }
}

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(...);
    }
}
json
{
    "dalmut/php-bench": "*"
    }
}