Skip to content

Instantly share code, notes, and snippets.

@milanchheda
Created February 26, 2017 10:20
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 milanchheda/a6539537177a972acca697febd7c08a8 to your computer and use it in GitHub Desktop.
Save milanchheda/a6539537177a972acca697febd7c08a8 to your computer and use it in GitHub Desktop.
Script Execution Time in PHP
<?php
//place this before any script you want to calculate time
$time_start = microtime(true);
//sample script
for($i=0; $i<1000; $i++){
//do anything
}
$time_end = microtime(true);
//dividing with 60 will give the execution time in minutes other wise seconds
$execution_time = ($time_end - $time_start)/60;
//execution time of the script in minutes
echo '<b>Total Execution Time:</b> '.$execution_time.' Mins';
//execution time of the script in seconds
echo 'Total execution time in seconds: ' . (microtime(true) - $time_start);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment