From bddcf288d8eae5f2f45d507babb3392f6048fd54 Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 18 Apr 2012 12:19:57 -0700 Subject: [PATCH] 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 --- .../PhabricatorXHProfProfileSymbolView.php | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php b/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php index 41aac4259a..123232b147 100644 --- a/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php +++ b/src/applications/xhprof/view/symbol/PhabricatorXHProfProfileSymbolView.php @@ -69,12 +69,13 @@ final class PhabricatorXHProfProfileSymbolView '', '', ); - $rows[] = array( - $this->renderSymbolLink($symbol), - $flat[$symbol]['ct'], - $flat[$symbol]['wt'], - '100%', - ); + $rows[] = $this->formatRow( + array( + $symbol, + $flat[$symbol]['ct'], + $flat[$symbol]['wt'], + 1.0, + )); $rows[] = array( 'Parent Calls', @@ -83,12 +84,13 @@ final class PhabricatorXHProfProfileSymbolView '', ); foreach ($parents as $key => $name) { - $rows[] = array( - $this->renderSymbolLink($name), - $data[$key]['ct'], - $data[$key]['wt'], - '', - ); + $rows[] = $this->formatRow( + array( + $name, + $data[$key]['ct'], + $data[$key]['wt'], + '', + )); } @@ -109,7 +111,9 @@ final class PhabricatorXHProfProfileSymbolView } $child_rows = isort($child_rows, 2); $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->setHeaders( @@ -134,17 +138,13 @@ final class PhabricatorXHProfProfileSymbolView return $panel->render(); } - private function formatRows($rows) { - $result = array(); - foreach ($rows as $row) { - $result[] = array( - $this->renderSymbolLink($row[0]), - number_format($row[1]), - number_format($row[2]).' us', - sprintf('%.1f%%', 100 * $row[3]), - ); - } - return $result; + private function formatRow(array $row) { + return array( + $this->renderSymbolLink($row[0]), + number_format($row[1]), + number_format($row[2]).' us', + ($row[3] != '' ? sprintf('%.1f%%', 100 * $row[3]) : ''), + ); } }