kanel / memoryusage
There is no license information available for the latest version (2.0.1) of this package.
a basic php lclass to track memory usage
2.0.1
2017-09-28 13:42 UTC
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: 6.0.8
This package is not auto-updated.
Last update: 2024-12-22 03:36:12 UTC
README
A simple Memory usage tracking class to benchmark functions or code execution memory consumption
#How it works :
- Start the memory tracking
MemoryUsage::start();
- Mark a place as a lap (the memory tracking will continue counting after returning the difference between the start and this lap)
Where $memoryUsage is instance of class :$memoryUsage = MemoryBench::lap();
class MemoryUsage { protected $memory; protected $realMemory; protected $memoryPeak; protected $realMemoryPeak; }
- If you want the memory used between this lap and the last one, send the following constant as a parameter:
$memoryUsage = MemoryBench::lap(MemoryBench::FROM_LAST_LAP);
- To stop the memory usage tracking and get the memory used from the beginning (the start)
$memoryUsage = MemoryBench::stop();
- To stop the memory tracking and get the memory used from the last lap
$memoryUsage = MemoryBench::stop(MemoryBench::FROM_LAST_LAP);
- To get the history of tracked memory
Where $memoryUsages is an array of MemoryUsage classes$memoryUsages = MemoryBench::getHistory();