Skip to content

Easily measure the time the amount of time elapsed between two points of your code

Notifications You must be signed in to change notification settings

joruro/stopwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stopwatch

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

About

Easily measure the time the amount of time elapsed between two points of your code

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages