PageGenerationTime

Summary: Display page generation time
Version: 2004-05-05
Prerequisites: Requires at least PmWiki version: 2.0beta; last tested on PmWiki version: pmwiki-2.0.beta35
Status:
Maintainer: Anno
Categories: Administration

Question

How long does pmwiki need to generate a page?

Answer

This recipe adds the time used to generate a page to the template. Sometimes when a page takes a long time to show up, this is a convenient means to see how long the script needs to generate the page.

Note that PmWiki has a built-in "`StopWatch" function that performs a lot of these timings as well. For instructions, see Stopwatch. (--Pm, CarlosAB)

Instructions

Into you local config.php file insert:

  
## Page generation timer recipe
$GenerationBegin = explode(' ', microtime());
$GenerationBegin = $GenerationBegin[0] + $GenerationBegin[1];
function GenerationTime(){
	global $GenerationBegin;
	$GenerationEnd = explode(' ', microtime());
	$GenerationEnd = $GenerationEnd[0] + $GenerationEnd[1];
	$GenerationTotal = $GenerationEnd - $GenerationBegin;
	$GenerationTotal = round($GenerationTotal, 3);
	print "$GenerationTotal";
}

In your template file (if you are using the default template the file is /pub/skins/pmwiki/pmwiki.tmpl )

search for:

 <!--/PageFooterFmt-->

insert just before the last [</div>]:

 
<br />
<small>Page generated in <!--function:GenerationTime--> seconds.</small>
<br />

Alternative Instructions

  • Download generationtime.phpΔ and place it in your cookbook directory.
  • Add include_once("$FarmD/cookbook/generationtime.php"); to your local/config.php.
  • Anywhere in a page where you want to output de measured value add (:GenerationTime:), for example in the TriadSkin? you could place it in Site.PageFooter.

Notes

See Also

  • Stopwatch - Use the $StopWatch function to measure PmWiki performance.

Contributors

Anno 2004-05-05

Comments

See discussion at PageGenerationTime-Talk

User notes +2: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.