Skip to content

Commit

Permalink
Add delegate profiling output (really quickly)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendo committed Sep 2, 2012
1 parent 4bcb376 commit c8f4c21
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions content/content.profile.php
Expand Up @@ -27,6 +27,7 @@ public function build() {
'general' => Symphony::Profiler()->retrieveGroup('General'),
'data-sources' => Symphony::Profiler()->retrieveGroup('Datasource'),
'events' => Symphony::Profiler()->retrieveGroup('Event'),
'delegates' => Symphony::Profiler()->retrieveGroup('Delegate'),
'slow-queries' => array()
);

Expand Down Expand Up @@ -66,6 +67,14 @@ protected function buildJump($wrapper) {
));
}

if (is_array($this->_records['delegates']) && !empty($this->_records['delegates'])) {
$list->appendChild($this->buildJumpItem(
__('Delegate Execution'),
'?profile=delegates' . $this->_query_string,
($this->_view == 'delegates')
));
}

$list->appendChild($this->buildJumpItem(
__('Full Page Render Statistics'),
'?profile=render-statistics' . $this->_query_string,
Expand Down Expand Up @@ -136,19 +145,16 @@ public function buildContent($wrapper) {
$row->appendChild(new XMLElement('td', $data[1]));
$table->appendChild($row);
}


}

elseif($this->_view == 'memory-usage'){
else if($this->_view == 'memory-usage'){
$items = Symphony::Profiler()->retrieve();

$base = $items[0][5];
$total = 0;
$last = 0;

foreach($items as $index => $item){

$row = new XMLElement('tr');
$row->appendChild(new XMLElement('th', ((in_array($item[3], array('Datasource','Event'))) ? $item[3] . ': ' : '') . $item[0]));
$row->appendChild(new XMLElement('td', General::formatFilesize(max(0, (($item[5]-$base) - $last)))));
Expand All @@ -158,8 +164,7 @@ public function buildContent($wrapper) {
}
}

elseif($this->_view == 'database-queries'){

else if($this->_view == 'database-queries'){
$debug = Symphony::Database()->debug();

if(count($debug) > 0){
Expand All @@ -173,7 +178,38 @@ public function buildContent($wrapper) {
$i++;
}
}
}

else if ($this->_view == 'delegates') {
$delegates = array();

// Build an array of delegate => extensions
foreach ($this->_records['delegates'] as $data) {
$parts = explode('|', $data[0]);
$data[0] = $parts[1];
$delegates[$parts[0]][] = $data;
}

foreach($delegates as $delegate => $extensions) {
$tt = 0;
$row = new XMLElement('tr');
$row->appendChild(new XMLElement('th', $delegate));
$table->appendChild($row);

foreach($extensions as $extension) {
$execution_time = number_format($extension[1], 4);
$extension_row = new XMLElement('tr');
// Poor man's grouping.
$extension_row->appendChild(new XMLElement('td', ' '));
$extension_row->appendChild(new XMLElement('th', $extension[0]));
$extension_row->appendChild(new XMLElement('td', $execution_time . ' s from ' . $extension[4] . ' ' . ($extension[4] == 1 ? 'query' : 'queries')));

$table->appendChild($extension_row);
$tt += $execution_time;
}

$row->appendChild(new XMLElement('td', number_format($tt, 4) . ' s'));
}
}

else if ($this->_records = $this->_records[$this->_view]) {
Expand Down

0 comments on commit c8f4c21

Please sign in to comment.