3 final class DarkConsoleXHProfPlugin
extends DarkConsolePlugin
{
5 protected $profileFilePHID;
7 public function getName() {
11 public function getColor() {
12 $data = $this->getData();
13 if ($data['profileFilePHID']) {
19 public function getDescription() {
20 return pht('Provides detailed PHP profiling information through XHProf.');
23 public function generateData() {
25 'profileFilePHID' => $this->profileFilePHID
,
26 'profileURI' => (string)$this
28 ->alter('__profile__', 'page'),
32 public function getXHProfRunID() {
33 return $this->profileFilePHID
;
36 public function renderPanel() {
37 $data = $this->getData();
39 $run = $data['profileFilePHID'];
40 $profile_uri = $data['profileURI'];
42 if (!DarkConsoleXHProfPluginAPI
::isProfilerAvailable()) {
43 $href = PhabricatorEnv
::getDoclink('Installation Guide');
44 $install_guide = phutil_tag(
48 'class' => 'bright-link',
50 pht('Installation Guide'));
52 '<div class="dark-console-no-content">%s</div>',
54 'The "xhprof" PHP extension is not available. Install xhprof '.
55 'to enable the XHProf console plugin. You can find instructions in '.
64 array('class' => 'dark-console-panel-header'),
69 'href' => $profile_uri,
70 'class' => $run ?
'disabled button' : 'button button-green',
73 phutil_tag('h1', array(), pht('XHProf Profiler')),
78 $result[] = phutil_tag(
81 'href' => "/xhprof/profile/$run/",
82 'class' => 'bright-link',
83 'style' => 'float: right; margin: 1em 2em 0 0; font-weight: bold;',
86 pht('Profile Permalink'));
87 $result[] = phutil_tag(
89 array('src' => "/xhprof/profile/$run/?frame=true"));
91 $result[] = phutil_tag(
93 array('class' => 'dark-console-no-content'),
95 'Profiling was not enabled for this page. Use the button above '.
99 return phutil_implode_html("\n", $result);
103 public function willShutdown() {
104 $this->profileFilePHID
= DarkConsoleXHProfPluginAPI
::getProfileFilePHID();