PHP code example of zdenekdrahos / profiler-tools

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

    

zdenekdrahos / profiler-tools example snippets

 php
// start stopwatch
$stopwatch = ProfilerTools\stopwatch();

// execute something

// stop timer
list($start, $end, $elapsedSeconds) = $stopwatch();

// log execution time
appendCsvLine(
    'log.csv'
    array(
        $start->format('c'),
        $end->format('c'),
        ProfilerTools\secondsToDays($elapsedSeconds)
    )
);

 php
$report = ProfilerTools\monitorExecution(function() {
    // execute something
});
ProfilerTools\appendCsvLine('log.csv', array(
    $report->dateStart->format('c'),
    $report->dateFinish->format('c'),
    $report->convertSecondsToReadableString(),
    $report->elapsedSeconds,
    $report->hasFailed() ? $report->exception->getMessage() : ''
));