Stopwatch

Summary: Use the $StopWatch function to measure PmWiki performance.
Version: 2007-04-17
Prerequisites:
Status: Stable
Maintainer: Petko
Categories: Administration, PHP72

Questions answered by this recipe

How can I measure the performance of my wiki?
How can I can see how long individual operations are taking to execute?

Description

The $StopWatch function allows you to measure the time it takes to generate wiki pages. It's a profiling/logging feature, so that you can see how long individual operations are taking to execute and to provide some debugging output.

Enabling the stopwatch

To enable the stopwatch, use:

$EnableDiag = 1;
$EnableStopWatch = 1;
$HTMLFooterFmt['stopwatch'] = 'function:StopWatchHTML 1';

Adding stopwatch entries

To add an entry to the stopwatch log (e.g., from a custom recipe or function), it's just

StopWatch('function_name message');

Notes

The first call to StopWatch() is always considered to be time "zero" -- all other times are relative to that. Setting $EnableStopWatch to 1 will display the wall-clock time; systems that support PHP's getrusage() function (typically Unix/Linux) can set $EnableStopWatch to 2 to get the wall-clock time and the CPU time.

Also, you can put "$StopWatch" somewhere in the skin template to see the stopwatch results.

Comments

See Discussion at Stopwatch-Talk?

See Also

PageGenerationTime

Contributors

User notes? : 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.