PHP code example of moznion / benchmarker

1. Go to this page and download the library: Download moznion/benchmarker 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/ */

    

moznion / benchmarker example snippets


$benchmarker = new \Moznion\Benchmarker("all");

$code = function () use ($foo) {
    // do something
};

$benchmarker->timeThese(10000, [
    "code A" => function () use ($bar) {
        // do something
    },
    "code B" => $code, // it can also take variable of anonymous function
]);
// Sample of Output:
//    code A: 3.9326 wallclock secs (3sr + 0.2562ys = PU)
//    code B: 6.40877 wallclock secs (6sr + 0.81337ys = PU)

$benchmarker->cmpThese(10000, [
    "code A" => function () use ($bar) {
        // do something
    },
    "code B" => $code, // it can also take variable of anonymous function
]);
// Sample of Output:
//               Rate  code A  code B
//    code A  22571/s      --    -49%
//    code B  44656/s     98%      --