Home Php PHP Generate a pages loading time Tutorial



PHP Generate a pages loading time Tutorial
Posted on: November 12, 2009 at 12:00 AM
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

 

Related Tags for PHP Generate a pages loading time Tutorial:


More Tutorials from this section

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

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.