kanel / benchmark
Benchmark your code by tracking duration and memory usage of your code
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/kanel/benchmark
Requires
- kanel/memoryusage: ~1.0.0
- kanel/timer: ~1.0.0
Requires (Dev)
- phpunit/phpunit: 6.0.8
This package is not auto-updated.
Last update: 2025-09-28 07:32:18 UTC
README
A simple tool to benchmark time execution and memory usage
#How it works :
-
Start the benchmarkg
Benchmark::start();
-
Mark a place as a lap (the benchmark will continue)
$usage = Benchmark::lap();
where $usage is an array :
[ 'time' => ..., 'memory' => ..., ]
-
If you want the benchmark between the two last laps, send the following parameter:
$usage = Benchmark::lap(Benchmark::FROM_LAST_LAP);
-
To stop the Benchmark and get the time/memory from the beginning (the start)
$usage = Benchmark::stop();
-
To stop the Benchmark tracking and get the memory used and duration from the last lap
$usage = Benchmark::stop(Benchmark::FROM_LAST_LAP);
-
To get the Benchmark history
$usage = Benchmark::getHistory();