joruro / stopwatch
Very simple stopwatch capable of register multi execution times.
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/joruro/stopwatch
Requires
- php: >=5.6.0
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2025-10-26 01:38:11 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);