Format metrics and parents in XHProf Profile

Test Plan: /xhprof/profile/PHID-FILE-.../?symbol=queryfx_all

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2274
This commit is contained in:
vrana
2012-04-18 12:19:57 -07:00
parent 1772410a2b
commit bddcf288d8

View File

@@ -69,12 +69,13 @@ final class PhabricatorXHProfProfileSymbolView
'', '',
'', '',
); );
$rows[] = array( $rows[] = $this->formatRow(
$this->renderSymbolLink($symbol), array(
$flat[$symbol]['ct'], $symbol,
$flat[$symbol]['wt'], $flat[$symbol]['ct'],
'100%', $flat[$symbol]['wt'],
); 1.0,
));
$rows[] = array( $rows[] = array(
'Parent Calls', 'Parent Calls',
@@ -83,12 +84,13 @@ final class PhabricatorXHProfProfileSymbolView
'', '',
); );
foreach ($parents as $key => $name) { foreach ($parents as $key => $name) {
$rows[] = array( $rows[] = $this->formatRow(
$this->renderSymbolLink($name), array(
$data[$key]['ct'], $name,
$data[$key]['wt'], $data[$key]['ct'],
'', $data[$key]['wt'],
); '',
));
} }
@@ -109,7 +111,9 @@ final class PhabricatorXHProfProfileSymbolView
} }
$child_rows = isort($child_rows, 2); $child_rows = isort($child_rows, 2);
$child_rows = array_reverse($child_rows); $child_rows = array_reverse($child_rows);
$rows = array_merge($rows, $this->formatRows($child_rows)); $rows = array_merge(
$rows,
array_map(array($this, 'formatRow'), $child_rows));
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);
$table->setHeaders( $table->setHeaders(
@@ -134,17 +138,13 @@ final class PhabricatorXHProfProfileSymbolView
return $panel->render(); return $panel->render();
} }
private function formatRows($rows) { private function formatRow(array $row) {
$result = array(); return array(
foreach ($rows as $row) { $this->renderSymbolLink($row[0]),
$result[] = array( number_format($row[1]),
$this->renderSymbolLink($row[0]), number_format($row[2]).' us',
number_format($row[1]), ($row[3] != '' ? sprintf('%.1f%%', 100 * $row[3]) : ''),
number_format($row[2]).' us', );
sprintf('%.1f%%', 100 * $row[3]),
);
}
return $result;
} }
} }