PHP code example of smoren / profiler
1. Go to this page and download the library: Download smoren/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/ */
smoren / profiler example snippets
use Smoren\Profiler\Profiler;
function someTask()
{
Profiler::start('first');
usleep(10000);
Profiler::stop('first');
Profiler::start('second');
usleep(20000);
Profiler::stop('second');
}
for($i=0; $i<10; ++$i) {
someTask();
}
Profiler::profile('third', function() {
usleep(30000);
});
print_r(Profiler::getStatTime());
/*
Array
(
[second] => 0.2015209197998
[third] => 0.20024418830872
[first] => 0.10135746002197
)
*/
print_r(Profiler::getStatCalls());
/*
Array
(
[first] => 10
[second] => 10
[third] => 1
)
*/