Calculating page loading time in PHP

Calculating page loading time in PHP

Description

Outputs the time in seconds that it takes for a PHP page to load.

Sample code

<?php

// Insert this block of code at the very top of your page:

$time = microtime();
$time = explode(” “, $time);
$time = $time[1] + $time[0];
$start = $time;
// All main codes comes here……….
// Place this part at the very end of your page

$time = microtime();
$time = explode(” “, $time);
$time = $time[1] + $time[0];
$finish = $time;
$totaltime = ($finish - $start);
printf (”This page took %f seconds to load.”, $totaltime);

?>

 

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.