Geekpedia Programming Tutorials






Show Page Load Time In PHP

Using a line of code at the beginning of the file and a function call at the end, you can count the number of milliseconds it took PHP to load the page.

On Wednesday, October 1st 2008 at 06:02 PM
By Andrew Pociu (View Profile)
-----   (Rated 0 with 0 votes)
Contextual Ads
More PHP Resources
Advertisement
  1. function PerfStopCount()
  2. {
  3.         global $StartAt;
  4.         $EndAt = time()+microtime();
  5.         $TimeElapsed = round($EndAt - $StartAt,4);
  6.         echo "Loaded in ".$TimeElapsed." milliseconds";
  7. }
  8. $StartAt = time() + microtime();
  9.  
  10. // The PHP code for the page has to go here (in the middle)
  11. // Sample time consuming code
  12. for($i = 0; $i < 100000; $i++)
  13. {
  14.         $i ^ 2;
  15. }
  16. // End sample
  17.  
  18. PerfStopCount();
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
by asfds on Thursday, October 2nd 2008 at 01:30 AM

ss

by asfds on Thursday, October 2nd 2008 at 01:30 AM

ss

by miles on Wednesday, October 8th 2008 at 11:57 AM

php loads pages?


Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs PHP Job Search
My skills include:

Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Download

Latest Icons