Hide options

Calculate and display site execution time

Small snippets to show the execution time of a script
<?php 
   //Create a variable for start time 
   $time_start = microtime(true); 
?>

<html>
 ...
</html>

<?php   
   //Create a variable for end time 
   $time_end = microtime(true); 
   
   //Subtract the two times to get seconds 
   $time = $time_end - $time_start; 

   echo 'Script took '.$time.' seconds to execute'; 
?>



Top