Page 1 of 1

parse times?

Posted: Fri Jan 23, 2004 7:23 am
by malcolmboston
i have heard alot of people talking about how fast there scripts parse in like 0.14 seconds etc.

just wanted to ask how you can find out?

Posted: Fri Jan 23, 2004 7:58 am
by qads
quite simple...

lets say this is a big script:

Code: Select all

<?php
$start_time = time();
//lines of code
//lines of code
//lines of code
//lines of code
//lines of code
//lines of code
$end = round(time() - $start_time, 3);
echo "Page parsed in ". $end." secs";
?>

Posted: Fri Jan 23, 2004 8:36 am
by twigletmac
To get the microseconds as well try this from the PHP manual:
php.net/microtime

Code: Select all

<?php
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\n";

?>
Mac