PHP Generate a pages loading time Tutorial

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


 
Ads

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

Ads
Share on Google+Share on Google+

PHP Generate a pages loading time Tutorial

Posted on: November 12, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: PHP Generate a pages loading time Tutorial  

Post your Comment


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

Ads

 

Ads