Jump to content

For some reason, ROUND will not give me time anymore. Please view code.


d22552000

Recommended Posts

Well, I have a problem with rounding time + microtime.  You will see what I mean below.  After much debugging I wrote this stupid thing, even though... IT USED TO BE ABLE TO JUST WRITE "echo $totaltime;"

 

It for some reason does this now... (THE PAGES TAKE ABOUT 4 SECONDS TO LOAD)

 

if ($totaltime<1) { 
$TEMPORARY = $totaltime;
$NEW = round($TEMPORARY,6);
echo "DEBUG MODE<br />";
echo "COME ON...: " . round($NEW) . "<br />"; // THIS ECHOS 0
echo "NEW: $NEW<br />"; // THIS ECHOS 4.6E-5
echo "OLD: $totaltime<br />"; // THIS ECHOS 4.60555267334E-5
}

 

PLEASE HELP ME!!!  (need it asap, this is on a PRODUCTION BOX (PHP 5))

that's technically correct.  it's rounding to the 6th decimal place, which in this instance only yields two digits since your number is:

 

0.000046[055526733]

 

are you looking for a certain number of significant digits?

I want a number like this (since it is the total time taken to display the page)

 

4.1615  (or something like that)

 

I even tried printf("The page took %f seconds to load",$totaltime,"formatstring");

I use this at the page start:

 

$starttime = explode(' ', microtime());
$starttime = (float)$starttime[1] + (float)$starttime[0];

 

and this at the page end:

 

$endtime = explode(' ', microtime());
$endtime = (float)$endtime[1] + (float)$endtime[0];
$totaltime = number_format(($endtime - $starttime), 3, '.', '');
echo "<p>My server generated this page in $totaltime seconds</p>";

 

Does that help?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.