1. Go to this page and download the library: Download dominicwatts/stopwatch 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/ */
dominicwatts / stopwatch example snippets
[...]
use Symfony\Component\Stopwatch\Stopwatch;
[...]
$stopwatch = new Stopwatch();
// starts event named 'eventName'
$stopwatch->start('eventName');
// ... run your code here
$event = $stopwatch->stop('eventName');
// you can convert $event into a string for a quick summary
// e.g. (string) $event = '4.50 MiB - 26 ms'
$event->getCategory(); // returns the category the event was started in
$event->getOrigin(); // returns the event start time in milliseconds
$event->ensureStopped(); // stops all periods not already stopped
$event->getStartTime(); // returns the start time of the very first period
$event->getEndTime(); // returns the end time of the very last period
$event->getDuration(); // returns the event duration, including all periods
$event->getMemory(); // returns the max memory usage of all periods