PHP code example of kevinlebrun / benchmark

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

    

kevinlebrun / benchmark example snippets


$echo = Benchmark::run(function ($b) {
    for ($i = 0; $i < $b->getN(); $i++) {
        echo "Something";
    }
}, 'echo');
$present($echo);

$sleep = Benchmark::run(function ($b) {
    sleep(2);

    // You can reset the timer in case of heavy bootstraping code
    $b->reset();
    for ($i = 0; $i < $b->getN(); $i++) {
        echo "Something";
    }
}, 'echo with bootstraping code');
$present($sleep);