1. Go to this page and download the library: Download davidbehler/timer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
davidbehler / timer example snippets
php
use DavidBehler\Timer\Timer;
$timer = new Timer;
php
$timer = new Timer(true, Timer::MICROTIME_TYPE);
php
$timer = new Timer(false);
php
$timer = new Timer(false);
$timer->start();
php
$timer = new Timer;
$timer->pause();
php
$timer = new Timer;
$timer->stop();
php
$timer = new Timer;
$timer->pause();
$timer->start();
php
$timer = new Timer;
$timer->restart();
php
$timer = new Timer;
usleep(1000);
$timer->getDuration(); // returns 0.001 (in a perfect world, but of course timings aren't this perfect)
php
$timer = new Timer;
usleep(500);
$timer->pause();
usleep(500);
$timer->getDuration(); // returns 0.0005 (in a perfect world, but of course timings aren't this perfect)
php
$timer = new Timer;
usleep(500);
$timer->stop();
usleep(500);
$timer->getDuration(); // returns 0.0005 (in a perfect world, but of course timings aren't this perfect)
php
$timer = new Timer;
sleep(1);
$timer->pause();
usleep(500);
$timer->start();
sleep(2);
$timer->pause();
$timer->getDuration(); // returns 3.005 (in a perfect world, but of course timings aren't this perfect)
php
$timer->getReport();
php
use DavidBehler\Timer\TimerCollection;
$timerCollection = new TimerCollection(Timer::MICROTIME_TYPE);
php
$timerCollection->getTimers(); // returns an array with all setup timers
$timerCollection->getTimers(true); // returns an array with all the setup timers' labels