Skip to content

Instantly share code, notes, and snippets.

@sadrul
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadrul/bb12560a716ed15dd44f to your computer and use it in GitHub Desktop.
Save sadrul/bb12560a716ed15dd44f to your computer and use it in GitHub Desktop.
Calculate Execution time
<?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