initphp/performance-meter

InitPHP Performance Meter / PHP Basic Profiler

1.0.1 2022-07-28 05:53 UTC

This package is auto-updated.

Last update: 2024-04-28 09:47:37 UTC


README

A helpful library that allows you to measure and compare the runtime of the code you write with PHP.

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Installation

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.

Usage

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."

Credits

License

Copyright © 2022 MIT License