Go Back   Internet Business Forums > Design & Development

Reply
 
Thread Tools Display Modes
Old 29-11-2006, 07:07 PM   #1 (permalink)
co-admin
 
army's Avatar
 
Join Date: Oct 2006
Location: Belgium
Posts: 666
Default [ SCRIPT ] Page Loading Timer

This timer is easy to implement and determines the time taken for a php script to execute correct to a microsecond.

Insert this code at the top of the page:
PHP Code:
<?php
$mtime 
microtime();
$mtime explode(" "$mtime);
$starttime $mtime[1] + $mtime[0];
?>
Then at the bottom of the page add the following:
PHP Code:
<?php
$mtime 
microtime();
$mtime explode(" "$mtime);
$endtime $mtime[1] + $mtime[0];
$totaltime = ($endtime $starttime);
echo 
"This page was created in $totaltime seconds.";
?>

Now lets break this code down, so you can understand it.
I retrieve the microtime at the tope of the page, and the end of the page by using PHP's microtime() function.

PHP's microtime() function returns the current Unix timestamp with microseconds.

Then I use the explode() function, to turn the string into an array. After that, I add the two parts of the array together, and assign a variable.

I do the same at the end of the document. Then I subtract the two times, and we have our loaded time!
army is offline   Reply With Quote
Old 29-11-2006, 08:26 PM   #2 (permalink)
Senior Member
 
syntex612's Avatar
 
Join Date: Aug 2006
Location: Paksitan
Posts: 148
Send a message via ICQ to syntex612 Send a message via AIM to syntex612 Send a message via MSN to syntex612 Send a message via Yahoo to syntex612
Default Re: [ SCRIPT ] Page Loading Timer

great tutorial army, very good tutorial thanks
syntex612 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


All times are GMT +1. The time now is 07:35 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.