joruro/stopwatch

Very simple stopwatch capable of register multi execution times.

v1.1.2 2016-09-04 10:44 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:36:34 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

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);