PHP code example of stk2k / bench
1. Go to this page and download the library: Download stk2k/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/ */
stk2k / bench example snippets
use Stk2k\Bench\TimeBenchmark;
$handle = TimeBenchmark::start();
// benchmark target code here
$score = TimeBenchmark::score($handle);
echo 'score: ' . $score . ' msec';
use Stk2k\Bench\MemoryBenchmark;
$handle = MemoryBenchmark::start();
// benchmark target code here
$score = MemoryBenchmark::score($handle);
$score = array_map(function($v){ return $v . 'MB'; }, $score);
echo 'score: ' . print_r($score, true);