Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

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. Simply set $EnableDiag = 1, and then put "$StopWatch" somewhere in the skin template to see the stopwatch results. --Pm
I have attempted to do as you have said (above), and no value is printed out. Does this "StopWatch" have anything to do with the $EnableStopWatch variable. -- MarkS
Instructions on how it works are here Stopwatch. 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 and Comments

Hi there, how do you use the generationtime.php within the template? (where the "powered by pmwiki" is?)

What would be a good value? Does the measured time show the time, the server need to generate the page, or pmwiki itself? What do values between 2.5 and 4 seconds show? Do I have a slow or fast "installation"???
Peter May 06, 2005, at 12:47 AM

The time is measured from loading the config.php file (which is one of the first things into the execution of the script) until loading the template file (which is one of the last things). So the time is an approximate measure of how long the script pmwiki.php needs to create the page.
2-4 seconds is rather slow.
On our site, which is on a shared server, it is considerably faster.
gobe.si
Anno

Have you got many extra cookbook things etc. loaded? I'm getting horrid execution times (2-3 s) and I don't know what to do to make things run more smoothly.

Sometimes I have execution times exceeding 5-10 seconds. Indeed, I have something around 13 cookbook things loaded, defining a lot of variables new depending to my (3) Wiki-Farms (titles, search-excludes etc.) and run my wiki like a cms with a login; and using some "if cases" to show up links only if someone is logged in. Does it eat up so much performance? What I have noticed is that includes (pages for sidebars, special noteblocks etc.) slow down the performance significant. As mentioned, some of these "if cases" are defined within the included pages, maybe this is the point. But, to give respect to pmwiki: my hoster seems to have problems with his performance too. There are moments, my wiki-execution-times are lower than 2 or 1,5 seconds - and sometimes (the same page) higher than 10-15 seconds. There is no rule to see.
Peter May 16, 2005, at 11:16 AM

Thanks for the recipe! Somehow I didn't manage to make the standard Stopwatch work, so it was great to have an alternative solution :-) I'm currently getting execution times of 1 to 2 seconds per normal page, and 30 seconds and more for pages using the WikiForms recipe despite using a brand-new and fairly powerful server. Times of this magnitude seem to be well below par for PmWiki installations, so I suppose I have messed something up :-( Any ideas on what I could try to narrow down the problem? I'm at a bit of a loss since I couldn't identify any particular problem, it's just that the entire wiki is slow, with WikiForms naturally being affected worst because it's the most performance-critical function to begin with. --Henning October 02, 2008, at 07:10 AM

See Also

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

Contributors

Anno 2004-05-05

Edit - History - Print - Recent Changes - Search
Page last modified on October 02, 2008, at 07:10 AM