PHP code example of appiusattaprobus / server-timing

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

    

appiusattaprobus / server-timing example snippets


use Appiusattaprobus\ServerTiming\StopWatch;

StopWatch::start('Task 1');

sleep(1); // do something

StopWatch::stop('Task 1');  // Not necessary. At set headers all timers stop
StopWatch::setTimingHeader();

$closureTimer = StopWatch::measureFunc('Closure', function () {
    usleep(500000);
});

StopWatch::start('Part');
sleep(1);
StopWatch::pause('Part');
sleep(3);
StopWatch::resume('Part');
sleep(1);
StopWatch::stop('Part');