Last active
August 29, 2015 14:07
-
-
Save sadrul/bb12560a716ed15dd44f to your computer and use it in GitHub Desktop.
Calculate Execution time
This file contains 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 | |
function time_elapsed($secs){ | |
$bit = array( | |
'y' => $secs / 31556926 % 12, | |
'w' => $secs / 604800 % 52, | |
'd' => $secs / 86400 % 7, | |
'h' => $secs / 3600 % 24, | |
'm' => $secs / 60 % 60, | |
's' => $secs % 60 | |
); | |
foreach($bit as $k => $v) | |
if($v > 0)$ret[] = $v . $k; | |
return join(' ', $ret); | |
} | |
$start = time(); | |
$end = time(); | |
print "time_elapsed_A: ".time_elapsed( $end - $start)."\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment