Code Snippets

  

PHP Source Code


Welcome to Dream.In.Code
Become a PHP Expert!

Join 148,803 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,169 people online right now. Registration is fast and FREE... Join Now!





Page Generation

This simple code will get the microtime (The server's time) and round it to 3 digits. This can obviously be changed, but both values need to be the same. It will then subtract the two times, leaving you with the time it took to generate the page! Remember to place the first part at the start of your document (Preferably before anything but the opening PHP tag) and the final part just above the closing PHP tag ;)

Submitted By: iamcenz
Actions:
Rating:
Views: 8,143

Language: PHP

Last Modified: February 16, 2005

Snippet


  1. // Insert at the start of your document
  2. $time = round(microtime(), 3);
  3.  
  4. // Insert at the end of your document
  5. $time2 = round(microtime(), 3);
  6.  
  7. $generation = $time2 - $time;
  8.  
  9. echo "This page took $generation seconds to render";

Copy & Paste


Comments


mifboy 2008-01-28 13:31:08

k:)


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.




Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month