PHP code example of alex-heifetz / stopwatch

1. Go to this page and download the library: Download alex-heifetz/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/ */

    

alex-heifetz / stopwatch example snippets




// Import Stopwatch class into the global namespace
use Heifetz\Stopwatch;

// Load Composer's autoloader
usleep(500000);
// Add first time measurement
$stopwatch->add('500000');

usleep(200000);
// Add another, this one must be skipped by threshold
$stopwatch->add('200000');

usleep(300000);
$stopwatch->add('300000');

// Display all timings 
print_r($stopwatch->getTimings());
// Result like:
//
// Array
// (
//     [500000] => 0.505021
//     [300000] => 0.300916
// )
//