Home Php PHP Generate a pages loading time Tutorial
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

PHP Generate a pages loading time Tutorial

Advertisement
Generate and display the amount of time taken to load and display a specific page, for debugging or display purposes.

PHP Page Loading Time

     

In the given example we will learn how to generate and display the amount of time taken to load and display a specific page, for debugging or display purposes.

To get the loading time of your page just put the following code at the top of your page (Before )and that's it... There is a lot of confusing code there that you don't really need to worry about, but all you need is to get the initial time and final time, and everything will be sorted.


Examples 1:

<?php

$m_time = explode(" ",microtime());

$m_time = $m_time[0] + $m_time[1];

$starttime = $m_time;

$m_time = explode(" ",microtime());

$m_time = $m_time[0] + $m_time[1];

$endtime = $m_time;

$totaltime = ($endtime - $starttime);

echo "<b>Page loading took:</b>". $totaltime." seconds<br/>";

echo "<b>You can round the time taken by using round() function</b><br/>";

echo "<b>Page loading took:</b>".round($totaltime)."seconds";

?>

Output:

Page loading took:2.7894973754883E-5 seconds
You can round the time taken by using round() function
Page loading took:0seconds

 

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 12, 2009

Ask Questions?    Discuss: PHP Generate a pages loading time Tutorial  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com