Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2890353
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
7 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/xhprof/controller/profile/PhabricatorXHProfProfileController.php b/src/applications/xhprof/controller/profile/PhabricatorXHProfProfileController.php
index 695aae2df1..6a361f7386 100644
--- a/src/applications/xhprof/controller/profile/PhabricatorXHProfProfileController.php
+++ b/src/applications/xhprof/controller/profile/PhabricatorXHProfProfileController.php
@@ -1,68 +1,69 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorXHProfProfileController
extends PhabricatorXHProfController {
private $phid;
public function willProcessRequest(array $data) {
$this->phid = $data['phid'];
}
public function processRequest() {
$file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$this->phid);
if (!$file) {
return new Aphront404Response();
}
$data = $file->loadFileData();
$data = unserialize($data);
if (!$data) {
throw new Exception("Failed to unserialize XHProf profile!");
}
$request = $this->getRequest();
$symbol = $request->getStr('symbol');
$is_framed = $request->getBool('frame');
if ($symbol) {
$view = new PhabricatorXHProfProfileSymbolView();
$view->setSymbol($symbol);
} else {
$view = new PhabricatorXHProfProfileTopLevelView();
+ $view->setFile($file);
$view->setLimit(100);
}
$view->setBaseURI($request->getRequestURI()->getPath());
$view->setIsFramed($is_framed);
$view->setProfileData($data);
return $this->buildStandardPageResponse(
$view,
array(
'title' => 'Profile',
'frame' => $is_framed,
));
}
}
diff --git a/src/applications/xhprof/view/toplevel/PhabricatorXHProfProfileTopLevelView.php b/src/applications/xhprof/view/toplevel/PhabricatorXHProfProfileTopLevelView.php
index cdeb8c6b29..a8155848fd 100644
--- a/src/applications/xhprof/view/toplevel/PhabricatorXHProfProfileTopLevelView.php
+++ b/src/applications/xhprof/view/toplevel/PhabricatorXHProfProfileTopLevelView.php
@@ -1,116 +1,158 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @phutil-external-symbol function xhprof_compute_flat_info
*/
final class PhabricatorXHProfProfileTopLevelView
extends PhabricatorXHProfProfileView {
private $profileData;
private $limit;
+ private $file;
public function setProfileData(array $data) {
$this->profileData = $data;
return $this;
}
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
+ public function setFile(PhabricatorFile $file) {
+ $this->file = $file;
+ return $this;
+ }
+
public function render() {
DarkConsoleXHProfPluginAPI::includeXHProfLib();
$GLOBALS['display_calls'] = true;
$totals = array();
$flat = xhprof_compute_flat_info($this->profileData, $totals);
unset($GLOBALS['display_calls']);
$aggregated = array();
foreach ($flat as $call => $counters) {
$parts = explode('@', $call, 2);
$agg_call = reset($parts);
if (empty($aggregated[$agg_call])) {
$aggregated[$agg_call] = $counters;
} else {
foreach ($aggregated[$agg_call] as $key => $val) {
if ($key != 'wt') {
$aggregated[$agg_call][$key] += $counters[$key];
}
}
}
}
$flat = $aggregated;
$flat = isort($flat, 'wt');
$flat = array_reverse($flat);
$rows = array();
$rows[] = array(
'Total',
number_format($totals['ct']),
number_format($totals['wt']).' us',
'100.0%',
number_format($totals['wt']).' us',
'100.0%',
);
if ($this->limit) {
$flat = array_slice($flat, 0, $this->limit);
}
foreach ($flat as $call => $counters) {
$rows[] = array(
$this->renderSymbolLink($call),
number_format($counters['ct']),
number_format($counters['wt']).' us',
sprintf('%.1f%%', 100 * $counters['wt'] / $totals['wt']),
number_format($counters['excl_wt']).' us',
sprintf('%.1f%%', 100 * $counters['excl_wt'] / $totals['wt']),
);
}
+ Javelin::initBehavior('phabricator-tooltips');
+
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Symbol',
'Count',
- 'Incl Wall Time',
+ javelin_render_tag(
+ 'span',
+ array(
+ 'sigil' => 'has-tooltip',
+ 'meta' => array(
+ 'tip' => 'Total wall time spent in this function and all of '.
+ 'its children (chilren are other functions it called '.
+ 'while executing).',
+ 'size' => 200,
+ ),
+ ),
+ 'Wall Time (Inclusive)'),
'%',
- 'Excl Wall Time',
+ javelin_render_tag(
+ 'span',
+ array(
+ 'sigil' => 'has-tooltip',
+ 'meta' => array(
+ 'tip' => 'Wall time spent in this function, excluding time '.
+ 'spent in children (children are other functions it '.
+ 'called while executing).',
+ 'size' => 200,
+ ),
+ ),
+ 'Wall Time (Exclusive)'),
'%',
));
$table->setColumnClasses(
array(
'wide pri',
'n',
'n',
'n',
'n',
'n',
));
$panel = new AphrontPanelView();
$panel->setHeader('XHProf Profile');
+
+ if ($this->file) {
+ $panel->addButton(
+ phutil_render_tag(
+ 'a',
+ array(
+ 'href' => $this->file->getBestURI(),
+ 'class' => 'green button',
+ ),
+ 'Download .xhprof Profile'));
+ }
+
$panel->appendChild($table);
return $panel->render();
}
}
diff --git a/src/applications/xhprof/view/toplevel/__init__.php b/src/applications/xhprof/view/toplevel/__init__.php
index 1602770d0f..87a8f48a57 100644
--- a/src/applications/xhprof/view/toplevel/__init__.php
+++ b/src/applications/xhprof/view/toplevel/__init__.php
@@ -1,17 +1,20 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/console/plugin/xhprof/api');
phutil_require_module('phabricator', 'applications/xhprof/view/base');
+phutil_require_module('phabricator', 'infrastructure/javelin/api');
+phutil_require_module('phabricator', 'infrastructure/javelin/markup');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');
+phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorXHProfProfileTopLevelView.php');
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 13:26 (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125050
Default Alt Text
(7 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment