Friday, 14 November 2014

Determine script run time or code execution time

<?php
  $starttime = microtime(true);
   
  // Start Code Excecution
   
  for ($i = 0; $i < 1000000; ++$i) {
    $a = $i;
  }
  // End Code Excecution
   
  $endttime = microtime(true);
   
  $duration = (float)($endttime-$starttime);
  $duration = number_format($duration,2,'.','');
  
  echo $duration." Seconds"; // result somthing like 0.88 Seconds
?>

0 comments:

Post a Comment