Time to load

On this way you can find out how long a page needs to load.

$start = time();
// put a long operation in here
$diff = time() - $start;
print "This page needed $diff seconds to load :-)";
// if you want a more exact value, you could use the 
// microtime function
Snippet Details

Sorry folks, comments have been deactivated for now due to the large amount of spam.

Please try to post your questions or problems on a related programming board, a suitable mailing list, a programming chat-room,
or use a QA website like stackoverflow because I'm usually too busy to answer any mails related
to my code snippets. Therefore please just mail me if you found a serious bug... Thank you!

Older comments:

Alex September 28, 2010 at 16:24
He uses the sleep function to show the 2 secounds delay. In a normal case your code should be placed where the sleep function is.
Kyle September 17, 2008 at 04:35
May i know why you are using the sleep function set at 2 second's?