Skip to content

Instantly share code, notes, and snippets.

@neerav
Created June 5, 2012 11:37
Show Gist options
  • Save neerav/2874507 to your computer and use it in GitHub Desktop.
Save neerav/2874507 to your computer and use it in GitHub Desktop.
Measure execution time of code block
<!-- put this at the top of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
?>
<!-- ******************************* -->
<!-- put other code and html in here -->
<!-- ******************************* -->
<!-- put this code at the bottom of the page -->
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo "Last code block was executed in ".$totaltime." seconds";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment