add some timing comments to output to debug poor performance

This commit is contained in:
Evan Prodromou 2011-04-06 18:33:05 -04:00
parent 29243cd21a
commit a2782523d7

View File

@ -118,7 +118,7 @@ class Action extends HTMLOutputter // lawsuit
} }
} }
function endHTML() function timingComment()
{ {
global $_startTime; global $_startTime;
@ -127,10 +127,15 @@ class Action extends HTMLOutputter // lawsuit
$diff = round(($endTime - $_startTime) * 1000); $diff = round(($endTime - $_startTime) * 1000);
$this->raw("<!-- ${diff}ms -->"); $this->raw("<!-- ${diff}ms -->");
} }
}
function endHTML()
{
$this->timingComment();
return parent::endHTML(); return parent::endHTML();
} }
/** /**
* Show head, a template method. * Show head, a template method.
* *
@ -139,6 +144,7 @@ class Action extends HTMLOutputter // lawsuit
function showHead() function showHead()
{ {
// XXX: attributes (profile?) // XXX: attributes (profile?)
$this->timingComment();
$this->elementStart('head'); $this->elementStart('head');
if (Event::handle('StartShowHeadElements', array($this))) { if (Event::handle('StartShowHeadElements', array($this))) {
if (Event::handle('StartShowHeadTitle', array($this))) { if (Event::handle('StartShowHeadTitle', array($this))) {
@ -154,6 +160,7 @@ class Action extends HTMLOutputter // lawsuit
Event::handle('EndShowHeadElements', array($this)); Event::handle('EndShowHeadElements', array($this));
} }
$this->elementEnd('head'); $this->elementEnd('head');
$this->timingComment();
} }
/** /**
@ -467,25 +474,31 @@ class Action extends HTMLOutputter // lawsuit
*/ */
function showBody() function showBody()
{ {
$this->timingComment();
$this->elementStart('body', (common_current_user()) ? array('id' => strtolower($this->trimmed('action')), $this->elementStart('body', (common_current_user()) ? array('id' => strtolower($this->trimmed('action')),
'class' => 'user_in') 'class' => 'user_in')
: array('id' => strtolower($this->trimmed('action')))); : array('id' => strtolower($this->trimmed('action'))));
$this->elementStart('div', array('id' => 'wrap')); $this->elementStart('div', array('id' => 'wrap'));
if (Event::handle('StartShowHeader', array($this))) { if (Event::handle('StartShowHeader', array($this))) {
$this->timingComment();
$this->showHeader(); $this->showHeader();
$this->flush(); $this->flush();
$this->timingComment();
Event::handle('EndShowHeader', array($this)); Event::handle('EndShowHeader', array($this));
} }
$this->showCore(); $this->showCore();
$this->flush(); $this->flush();
if (Event::handle('StartShowFooter', array($this))) { if (Event::handle('StartShowFooter', array($this))) {
$this->timingComment();
$this->showFooter(); $this->showFooter();
$this->flush(); $this->flush();
$this->timingComment();
Event::handle('EndShowFooter', array($this)); Event::handle('EndShowFooter', array($this));
} }
$this->elementEnd('div'); $this->elementEnd('div');
$this->showScripts(); $this->showScripts();
$this->elementEnd('body'); $this->elementEnd('body');
$this->timingComment();
} }
/** /**
@ -703,18 +716,24 @@ class Action extends HTMLOutputter // lawsuit
$this->elementStart('div', array('id' => 'content_wrapper')); $this->elementStart('div', array('id' => 'content_wrapper'));
$this->elementStart('div', array('id' => 'site_nav_local_views_wrapper')); $this->elementStart('div', array('id' => 'site_nav_local_views_wrapper'));
if (Event::handle('StartShowLocalNavBlock', array($this))) { if (Event::handle('StartShowLocalNavBlock', array($this))) {
$this->timingComment();
$this->showLocalNavBlock(); $this->showLocalNavBlock();
$this->flush(); $this->flush();
$this->timingComment();
Event::handle('EndShowLocalNavBlock', array($this)); Event::handle('EndShowLocalNavBlock', array($this));
} }
if (Event::handle('StartShowContentBlock', array($this))) { if (Event::handle('StartShowContentBlock', array($this))) {
$this->timingComment();
$this->showContentBlock(); $this->showContentBlock();
$this->flush(); $this->flush();
$this->timingComment();
Event::handle('EndShowContentBlock', array($this)); Event::handle('EndShowContentBlock', array($this));
} }
if (Event::handle('StartShowAside', array($this))) { if (Event::handle('StartShowAside', array($this))) {
$this->timingComment();
$this->showAside(); $this->showAside();
$this->flush(); $this->flush();
$this->timingComment();
Event::handle('EndShowAside', array($this)); Event::handle('EndShowAside', array($this));
} }
$this->elementEnd('div'); $this->elementEnd('div');