Thursday, 29 May 2014

- Execution time In Php & Javascript

php:
$startTime =  microtime(true);
// do functionality here
$endTime =  microtime(true);
echo " Time Taken: " . number_format(($endTime - $startTime),2) . " sec";

javascript:

var start = new Date().getTime();
// do functionality here
var end = new Date().getTime();
var diff = end - start;
//Result will be in miliseconds..
" Time taken " +  (diff/1000)%60 +" sec"; 

No comments:

Post a Comment