joruro / stopwatch
Very simple stopwatch capable of register multi execution times.
v1.1.2
2016-09-04 10:44 UTC
Requires
- php: >=5.6.0
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-10-26 20:26:18 UTC
README
Stopwatch is a very simple tool for measuring the execution time of multiple parts of your code.
Example of usage
<?php include('../vendor/autoload.php'); use Joruro\Enum\TimeUnits; use Joruro\Stopwatch\Stopwatch; $attempts = 2; $counter = 5; Stopwatch::start(); for ($j = 0; $j < $attempts; $j++) { Stopwatch::start(); for ($i = 0; $i < $counter; $i++) { sleep(1); } $time = Stopwatch::stop(TimeUnits::SECONDS); echo "A foreach of {$counter} loops took approximately {$time} seconds\n"; } $time = Stopwatch::stop(TimeUnits::SECONDS); echo "{$attempts} attempts foreach of {$counter} loops took approximately {$time} seconds\n"; exit(0);