Last active
August 30, 2016 13:36
-
-
Save g4vroche/270091bb48c5e4afd7c0d1e7ecdc6150 to your computer and use it in GitHub Desktop.
PHP time debugger
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$GLOBALS['timer'] = ['latest' => microtime(true), 'results' => []]; | |
timer(__FILE__, __LINE__, "init"); | |
function timer($file, $line, $label = false) | |
{ | |
$time = microtime(true); | |
$GLOBALS['timer']['results'][] = [ | |
'ellapsed' => round($time - $GLOBALS['timer']['latest'], 4), | |
'from_start' => round($time - $GLOBALS['timer']['results'][0]['time'],3), | |
'time' => $time, | |
'file' => $file, | |
'line' => $line, | |
'label' => $label | |
]; | |
$GLOBALS['timer']['latest'] = $time; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment