Page 1 of 1
Page generated time
Posted: Mon Sep 06, 2010 11:01 am
by swarfega
Hi all. I would like to show the time a page is generated in. You get these at the bottom of some websites saying something like "Page generated in blah seconds".
Re: Page generated time
Posted: Mon Sep 06, 2010 1:04 pm
by spcherub
This is built into the configuration and you can turn it on by setting the show_performance_info variable in config.php to "true" (or anything else). This will print the performance information within HTML comments after the closing tag, so by default it is only visible upon doing a View->Source on the page.
If you want to actually display these numbers on the page, you will need to write a UDT that essentially does exactly what the code at the end of index.php does, namely:
Code: Select all
echo "This page was generated in ".microtime_diff($starttime,$endtime)." microseconds\n";
NOTE: I have not tested the above code, but the intent is correct. You will need to make sure that $starttime and $endtime value set in index.php are available globally or otherwise.
Hope that helps.
Sanjay
Re: Page generated time
Posted: Mon Sep 06, 2010 1:21 pm
by swarfega
Thanks for your reply. For some reason its not showing.
In global settings Ive put:
Code: Select all
<? $m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$starttime = $m_time;
?>
In a footer block Ive put:
Code: Select all
<?
$round = 3;// The number of decimal places to round the micro time to.
$m_time = explode(" ",microtime());
$m_time = $m_time[0] + $m_time[1];
$endtime = $m_time;
$totaltime = ($endtime - $starttime);
echo "This page was generated in ". microtime_diff($totaltime,$round) ." microseconds";
?>