A helpful library that allows you to measure and compare the runtime of the code you write with PHP.
composer require initphp/performance-meter
This is a library consisting of a single file and a single class. You can choose to manually include the src/PerformanceMeter.php
file in the project. However, I recommend Composer to manage patches and updates more easily.
require_once "../vendor/autoload.php";
use InitPHP\PerformanceMeter\PerformanceMeter;
PerformanceMeter::setPointer('main');
for($i = 0; $i <= 1000; $i++){
usleep(10);
}
PerformanceMeter::setPointer('mainEnd');
echo PerformanceMeter::elapsedTime('main', 'mainEnd', 3) . ' seconds passed ';
echo PerformanceMeter::memoryUsage('main', 'mainend', 2) . ' memory used.';
// Output : "15.204 seconds passed 0.77KB memory used."
Copyright © 2022 MIT License