note 87215 modified in ref.outcontrol by danbrown
| From: | danbrown@php.net | Date: | Tue, 25 Nov 2008 15:56:46 +0000 |
| Subject: | note 87215 modified in ref.outcontrol by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146931@lists.php.net to get a copy of this message | ||
Sometimes users are blaming about slow pages ... not being aware that mostly this is due to network
issues.
So I've decided to add some statistics at the end of my pages:
At beginning I start the counters:
<?php
function microtime_float() {
if (version_compare(PHP_VERSION, '5.0.0', '>')) return microtime(true);
list($u,$s)=explode(' ',microtime()); return ((float)$u+(float)$s);
}
$initime=microtime_float();
ob_start();
ob_implicit_flush();
?>
And at the end I show the statistics:
<?php
echo "PHP Time: ".round((microtime_float()-$initime)*1000)." msecs. ";
echo "Size: ".round_byte(strlen(ob_get_contents()));
ob_end_flush();
?>
(round_byte is my function to print byte sizes)
--was--
Sometimes users are blaming about slow pages ... not being aware that mostly this is due to network
issues.
So I've decided to add some statistics at the end of my pages:
At beginning I start the counters:
function microtime_float() {
if (version_compare(PHP_VERSION, '5.0.0', '>')) return microtime(true);
list($u,$s)=explode(' ',microtime()); return ((float)$u+(float)$s);
}
$initime=microtime_float();
ob_start();
ob_implicit_flush();
And at the end I show the statistics:
echo "PHP Time: ".round((microtime_float()-$initime)*1000)." msecs. ";
echo "Size: ".round_byte(strlen(ob_get_contents()));
ob_end_flush();
(round_byte is my function to print byte sizes)
http://php.net/manual/en/ref.outcontrol.php