PHP code example of disfasia / php-timing
1. Go to this page and download the library: Download disfasia/php-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/ */
disfasia / php-timing example snippets
Timing::start('random calc');
for ($i = 0; $i < 10000; $i++) {
$r = rand();
}
Timing::stop('random calc');
$returnVal = 0;
for ($i = 1; $i < 3; $i++) {
$returnVal += Timing::measure('someFunction('.$i.')', function() use ($i) {
sleep($i);
return $i;
});
}
var_dump($returnVal);
Timing::addCallback(function($key, $time) {
var_dump("Collected timing for: $key: ". round($time,4));
});