2011-02-02 22:48:52 +01:00
|
|
|
<?php
|
|
|
|
|
2011-09-14 17:02:31 +02:00
|
|
|
/**
|
|
|
|
* @group console
|
|
|
|
*/
|
2012-03-13 19:18:11 +01:00
|
|
|
final class DarkConsoleXHProfPlugin extends DarkConsolePlugin {
|
2011-02-02 22:48:52 +01:00
|
|
|
|
|
|
|
protected $xhprofID;
|
|
|
|
|
|
|
|
public function getName() {
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
return 'XHProf';
|
|
|
|
}
|
2011-02-02 22:48:52 +01:00
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
public function getColor() {
|
|
|
|
$data = $this->getData();
|
|
|
|
if ($data['xhprofID']) {
|
|
|
|
return '#ff00ff';
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
return null;
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
|
|
|
return 'Provides detailed PHP profiling information through XHProf.';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function generateData() {
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
return array(
|
|
|
|
'xhprofID' => $this->xhprofID,
|
|
|
|
'profileURI' => (string)$this
|
|
|
|
->getRequestURI()
|
|
|
|
->alter('__profile__', 'page'),
|
|
|
|
);
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getXHProfRunID() {
|
|
|
|
return $this->xhprofID;
|
|
|
|
}
|
|
|
|
|
DarkConsole: fix rendering, move request log, load over ajax
Summary:
This accomplishes three major goals:
# Fixes phutil_render_tag -> phutil_tag callsites in DarkConsole.
# Moves the Ajax request log to a new panel on the left. This panel (and the tabs panel) get scrollbars when they get large, instead of making the page constantly scroll down.
# Loads the panel content over ajax, instead of dumping it into the page body / ajax response body. I've been planning to do this for about 3 years, which is why the plugins are architected the way they are. This should make debugging easier by making response bodies not be 50%+ darkconsole stuff.
Additionally, load the plugins dynamically (the old method predates library maps and PhutilSymbolLoader).
Test Plan:
{F30675}
- Switched between requests and tabs, reloaded page, saw same tab.
- Used "analyze queries", "profile page", triggered errors.
- Verified page does not load anything by default if dark console is closed with Charles.
- Generally banged on it a bit.
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2432
Differential Revision: https://secure.phabricator.com/D4692
2013-01-29 03:45:32 +01:00
|
|
|
public function renderPanel() {
|
|
|
|
$data = $this->getData();
|
|
|
|
|
|
|
|
$run = $data['xhprofID'];
|
|
|
|
$profile_uri = $data['profileURI'];
|
|
|
|
|
2011-02-02 22:48:52 +01:00
|
|
|
if (!DarkConsoleXHProfPluginAPI::isProfilerAvailable()) {
|
2011-07-09 18:45:19 +02:00
|
|
|
$href = PhabricatorEnv::getDoclink('article/Installation_Guide.html');
|
2013-01-18 03:57:09 +01:00
|
|
|
$install_guide = phutil_tag(
|
2011-07-09 18:45:19 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $href,
|
|
|
|
'class' => 'bright-link',
|
|
|
|
),
|
|
|
|
'Installation Guide');
|
2013-02-13 23:08:57 +01:00
|
|
|
return
|
2011-07-09 18:45:19 +02:00
|
|
|
'<div class="dark-console-no-content">'.
|
|
|
|
'The "xhprof" PHP extension is not available. Install xhprof '.
|
|
|
|
'to enable the XHProf console plugin. You can find instructions in '.
|
2013-02-13 23:08:57 +01:00
|
|
|
'the '.$install_guide.'.'.
|
|
|
|
'</div>';
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
2011-02-06 21:58:01 +01:00
|
|
|
|
2011-07-09 18:45:19 +02:00
|
|
|
$result = array();
|
|
|
|
|
2013-02-13 23:08:57 +01:00
|
|
|
$header =
|
2011-07-09 18:45:19 +02:00
|
|
|
'<div class="dark-console-panel-header">'.
|
2013-02-13 23:08:57 +01:00
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $profile_uri,
|
|
|
|
'class' => $run
|
|
|
|
? 'disabled button'
|
|
|
|
: 'green button',
|
|
|
|
),
|
|
|
|
'Profile Page').
|
2011-07-09 18:45:19 +02:00
|
|
|
'<h1>XHProf Profiler</h1>'.
|
2013-02-13 23:08:57 +01:00
|
|
|
'</div>';
|
2011-07-09 18:45:19 +02:00
|
|
|
$result[] = $header;
|
2011-02-06 21:58:01 +01:00
|
|
|
|
2011-07-09 18:45:19 +02:00
|
|
|
if ($run) {
|
2013-02-13 23:08:57 +01:00
|
|
|
$result[] =
|
|
|
|
'<a href="/xhprof/profile/'.$run.'/" '.
|
2011-07-09 18:45:19 +02:00
|
|
|
'class="bright-link" '.
|
|
|
|
'style="float: right; margin: 1em 2em 0 0;'.
|
|
|
|
'font-weight: bold;" '.
|
|
|
|
'target="_blank">Profile Permalink</a>'.
|
2013-02-13 23:08:57 +01:00
|
|
|
'<iframe src="/xhprof/profile/'.$run.'/?frame=true"></iframe>';
|
2011-07-09 18:45:19 +02:00
|
|
|
} else {
|
2013-02-13 23:08:57 +01:00
|
|
|
$result[] =
|
2011-07-09 18:45:19 +02:00
|
|
|
'<div class="dark-console-no-content">'.
|
|
|
|
'Profiling was not enabled for this page. Use the button above '.
|
|
|
|
'to enable it.'.
|
2013-02-13 23:08:57 +01:00
|
|
|
'</div>';
|
2011-02-03 01:14:23 +01:00
|
|
|
}
|
2011-07-09 18:45:19 +02:00
|
|
|
|
2013-02-13 23:08:57 +01:00
|
|
|
return implode("\n", $result);
|
2011-02-03 01:14:23 +01:00
|
|
|
}
|
|
|
|
|
2011-02-02 22:48:52 +01:00
|
|
|
|
2011-02-03 01:14:23 +01:00
|
|
|
public function willShutdown() {
|
2013-02-10 00:47:55 +01:00
|
|
|
if (DarkConsoleXHProfPluginAPI::isProfilerStarted()) {
|
2011-02-03 01:14:23 +01:00
|
|
|
$this->xhprofID = DarkConsoleXHProfPluginAPI::stopProfiler();
|
|
|
|
}
|
2011-02-02 22:48:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|