How could I measure the time taken to load a page (with various different PHP statements)?
Somewhat like the stats available here - http://talks.php.net/show/drupal08/24
method two: Put these statements all around your your scripts
$TIMER['label']=microtime(1);
/* some code */
$TIMER['sql1_before']=microtime(1);
a/* some code */
$TIMER['sql1_after']=microtime(1);
/* some code */
and then output it, with code like this:
echo "name so far delta per cent ";
reset($TIMER);
$start=$prev=current($TIMER);
$total=end($TIMER)-$start;
foreach($TIMER as $name => $value) {
$sofar=round($value-$start,3);
$delta=round($value-$prev,3);
$percent=round($delta/$total*100);
echo "$name $sofar $delta $percent ";
$prev=$value;
}
echo "
";
Thus, you'll get tetailed report on how your code goes.
this action called profiling
and take most important place in the optimization process.