PHP code example of sohelrana820 / php-benchmark
1. Go to this page and download the library: Download sohelrana820/php-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/ */
sohelrana820 / php-benchmark example snippets
hmark = new \SohelRana820\Benchmark\Benchmark();
$benchmark->start();
for ($counter = 0; $counter < 100000; $counter++) {
// Write some code to execute
}
$benchmark->end();
echo $benchmark->getTime(); // 10ms
echo $benchmark->getTime(true); // 0.010242
echo $benchmark->getMemoryUsage(); // 2.00Mb
echo $benchmark->getMemoryUsage(true); // 2097152 bit
echo $benchmark->getMemoryUsage(false, '%.3f%s'); // 2.000Mb
echo $benchmark->getPeakMemory(); // 2.00Mb
echo $benchmark->getPeakMemory(true); // 2097152 b
echo $benchmark->getPeakMemory(false, '%.3f%s'); // 2.000Mb