Create Account
Sign In

PHP Script execution timer - loading page microtime timer execution time


PHP Script execution timer - loading page microtime timer execution time PHP Script execution timer - loading page microtime timer execution time The 09/08/2010 at 19:01:48
Rating: 4/5
Keywords: execution time microtime chronometer page loading php script function microtime execution page generated

Hi,
In this script, I will show you how to get the execution time of a script an to display it.
This script is very simple, we will get the micro-seconds in the beginning and in the and of the script using the microtime function of PHP. Then, we will do a subtraction to get the elapsed time during the script execution.
This is the code to use:
<?php
function timer()
{
    $time = explode(' ', microtime());
    return $time[0]+$time[1];
}
$beginning = timer();
?>
<html>
    <!-- The content of your page -->
        Page generated in <?php echo round(timer()-$beginning,6); ?> seconds.
    </body>
</html>
I hope this script will be useful.

Similar Scripts and Tutorials

Number of mysql queries and execution time - query counter mysql timing php Number of mysql queries and execution time - query counter mysql timing php PHP Redirection (Header and URL Rewrite) - redirect php page header location RewriteRule PHP Redirection (Header and URL Rewrite) - redirect php page header location RewriteRule Top site PHP script - install a php top site on his web site Top site PHP script - install a php top site on his web site Go to previous and next page in Javascript - history object Go to previous and next page in Javascript - history object Custom 404 error pages - php url rewrite ErrorDocument not found htaccess Custom 404 error pages - php url rewrite ErrorDocument not found htaccess