PHP code example of perf / timing
1. Go to this page and download the library: Download perf/timing 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/ */
perf / timing example snippets
use perf\Timing\Clock;
$clock = new Clock();
// Will output something like "2020-01-23"
echo $clock->getDateString();
// Will output something like "15:16:17"
echo $clock->getTimeString();
// Will output something like "2020-01-23 15:16:17"
echo $clock->getDateTimeString();
// Will output something like "123456789"
echo $clock->getTimestamp();
// Will output something like "123456789.0123"
echo $clock->getMicrotime();
use perf\Timing\Timer;
$timer = new Timer();
sleep(1);
// Will output something like "0.0"
echo $timer->getElapsed();
$timer->start();
sleep(1);
// Will output something like "1.0023456"
echo $timer->getElapsed();
sleep(1);
$timer->stop();
sleep(1);
// Will output something like "2.0034567"
echo $timer->getElapsed();
$timer->restart();
sleep(1);
// Will output something like "1.0023456"
echo $timer->getElapsed();
sleep(1);
// Will output something like "2.0034567"
echo $timer->getElapsed();
$timer->reset();
sleep(1);
// Will output something like "0.0"
echo $timer->getElapsed();