PHP code example of gamernetwork / yolk-profiler

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

    

gamernetwork / yolk-profiler example snippets


use yolk\profiler\GenericProfiler;

$profiler = new GenericProfiler();

$profiler->start('Op 1');
lengthyOperation1();
$profiler->stop('Op 1');

$profiler->start('Op 2');
lengthyOperation2();
$profiler->stop('Op 2');

// profile a query
$profiler->start('Query1');
doDatabaseQuery($sql, $params);
$profiler->stop('Query1');

$profiler->query($sql, $params, $profiler->getElapsed('Query1'));

// add some additional info
$profiler->meta('get', $_GET);
$profiler->meta('post', $_POST);

$profiler->stop();

// assign a configuration object to the profiler to be 

use yolk\profiler\GenericTimer;

$t = new GenericTimer();

$t->start();
$t->isRunning();	// returns true
$t->getElapsed();	// returns microseconds since last call to start()
$t->stop();
$t->isRunning();	// returns false
$t->getTotalElapsed();	// returns microseconds between all calls to start()/stop()