Hello me again
Please can you tell me how they execute this kind of timer on the page
"[i]phpBB Created this page in 0.220205 seconds : 15 queries executed : GZIP compression enabled[/i]"
If posible please leave an example (I fairly new at all of this)
Thanx a stack
Page Timerz
Moderator: General Moderators
I am thinking that you could use gmdate at the beginning and end of the script to do something like that.
For example this might work but I am just typing it out so if it don't work don't blame me:)
For example this might work but I am just typing it out so if it don't work don't blame me:)
Code: Select all
//Put this at the top of the script
<?php
function calc($script_started_at, $script_ended_at,&$time_to_execute)
{
$time_to_execute = ($script_ended_at - $script_started_at);
return $time_to_execute;
}
$script_started_at = gmdate(U);
?>
//Put this at the bottom of the script
<?php
$script_ended_at = gmdate(U);
calc($script_started_at,$script_ended_at);
echo "This page created in " . $time_to_execute . "seconds.";
?>Here ya go I found some code online that will do the trick...
On my box this returned..
Code: Select all
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
for ($i=0; $i < 1000; $i++){
//do nothing, 1000 times
}
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds";On my box this returned..
Anyone wanna raceDid nothing in 0.0010370016098022 seconds
-
Chillwabbitt
- Forum Newbie
- Posts: 8
- Joined: Fri May 24, 2002 3:04 am
Page Timerz
Tang Ya Belly Much :D