PHP code example of sapiet / profiler

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

    

sapiet / profiler example snippets




use Sapiet\Profiler\Profiler;

$number = 50000000;

// Starts a test named 'test-1'
Profiler::start('test-1');
foreach (range(1, $number) as $value) {
    // echo $value;
}
// Ends the test named 'test-1'
$test1 = Profiler::end('test-1');

// Starts a test named 'test-2'
Profiler::start('test-2');
function xrange($min, $max) {
    for ($i = $min; $i < $max; $i++) yield $i;
}

foreach (xrange(1, $number) as $value) {
    // echo $value;
}
// Ends the test named 'test-2'
$test2 = Profiler::end('test-2');

// Displaying test results
echo $test1->format();
echo PHP_EOL;
echo $test2->format();