PHP code example of fetzi / server-timing

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

    

fetzi / server-timing example snippets


$app->add(new ServerTimingMiddleware($container->get(ServerTimings::class)));

function fetchUsers()
{
    $fetchUsers = $this->serverTimings->create('fetchUsers');
    $fetchUsers->start();
    $users = $this->db->getUsers();
    $fetchUsers->stop();

    return $users;
}

// create a ServerTiming with a name
$serverTiming = $serverTimings->create('foo');

// create a ServerTiming with a name and a description
$serverTiming = $serverTimings->create('foo', 'bar');

// normal usage
$serverTiming->start();
// ...
$serverTiming->stop();

// set a manual start value (a microtime value as float)
$serverTiming->start(1000000.00);
// ...
$serverTiming->stop();