diff options
author | pmichaud <pmichaud@524c5546-5005-0410-9a3e-e25e191bd360> | 2004-09-23 17:23:34 +0000 |
---|---|---|
committer | pmichaud <pmichaud@524c5546-5005-0410-9a3e-e25e191bd360> | 2004-09-23 17:23:34 +0000 |
commit | ced97f0e79dcf3e6407ddf2d281c95ce3a979f19 (patch) | |
tree | f941143c9f5cb904eb1a51fda5945f0ccafa076c /scripts/diag.php | |
parent | d1d002ee91f817abccc84e8d789f6de225578c9e (diff) | |
download | pmwiki.svn-ced97f0e79dcf3e6407ddf2d281c95ce3a979f19.tar.bz2 |
Updated StopWatch functions for timing performance.
git-svn-id: svn://pmwiki.org/trunk/pmwiki@193 524c5546-5005-0410-9a3e-e25e191bd360
Diffstat (limited to 'scripts/diag.php')
-rw-r--r-- | scripts/diag.php | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/scripts/diag.php b/scripts/diag.php index 1bf994dc..130aa680 100644 --- a/scripts/diag.php +++ b/scripts/diag.php @@ -36,16 +36,25 @@ function HandleRuleset($pagename) { print Ruleset(); } -function Elapsed($a,$b=NULL) { - if (!$b) $b = microtime(); - list($au,$as) = explode(' ',$a); - list($bu,$bs) = explode(' ',$b); - return round($bs + $bu - $as - $au,2); +function DisplayStopWatch() { + global $StopWatch; + StopWatch('now'); + $u = $StopWatch[0]; + $au=$u; + $out[] = "<table><th>Event</th><th>Time</th><th>Cumulative</th>\n"; + for($i=0;$i<count($StopWatch);$i++) { + list($bu,$bevent) = explode(' ',$StopWatch[$i],2); + $t = sprintf('%.02f',$bu-$au); + $c = sprintf('%.02f',$bu-$u); + $out[] = "<tr><td>$bevent</td> + <td align='right'>$t</td><td align='right'>$c</td></tr>"; + $au=$bu; + } + array_pop($StopWatch); + $out[] = '</table>'; + return implode('',$out); } -$FmtVP['/\\$ElapsedPmWiki/e'] = - "Elapsed(\$GLOBALS['StopWatch']['PmWiki'])"; -$FmtVP['/\\$ElapsedMarkup/e'] = - "Elapsed(\$GLOBALS['StopWatch']['MarkupToHTML'], - \$GLOBALS['StopWatch']['MarkupToHTMLEnd'])"; +$FmtP['/\\$StopWatch/e'] = 'DisplayStopWatch()'; + ?> |