PHP code example of loophp / nanobench

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

    

loophp / nanobench example snippets




declare(strict_types=1);

namespace App;

use loophp\nanobench\Benchmark;
use loophp\nanobench\Time\HrClock;
use loophp\nanobench\Time\Stopwatch;

topwatch(new HrClock()), $callable, 3);
$duration = $benchmark->run()->getDuration();

$duration->asNanosecond();
$duration->asMicrosecond();
$duration->asMillisecond();
$duration->asSecond();

$benchmark->getReturn(); // Return value of the callable that has been benchmarked