Differential D13956 Diff 33689 src/applications/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/console/plugin/xhprof/DarkConsoleXHProfPluginAPI.php
| Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | public static function hookProfiler() { | ||||
| if (self::$profilerStarted) { | if (self::$profilerStarted) { | ||||
| return; | return; | ||||
| } | } | ||||
| self::startProfiler(); | self::startProfiler(); | ||||
| } | } | ||||
| /** | |||||
| * @phutil-external-symbol class PhabricatorStartup | |||||
| */ | |||||
| private static function startProfiler() { | private static function startProfiler() { | ||||
| PhabricatorStartup::beginStartupPhase('profiler.init'); | |||||
| self::includeXHProfLib(); | self::includeXHProfLib(); | ||||
| xhprof_enable(); | xhprof_enable(); | ||||
| self::$profilerStarted = true; | self::$profilerStarted = true; | ||||
| self::$profilerRunning = true; | self::$profilerRunning = true; | ||||
| } | } | ||||
| /** | |||||
| * @phutil-external-symbol class PhabricatorStartup | |||||
| */ | |||||
| public static function getProfileFilePHID() { | public static function getProfileFilePHID() { | ||||
| if (!self::isProfilerRunning()) { | |||||
| return; | |||||
| } | |||||
| PhabricatorStartup::beginStartupPhase('profiler.stop'); | |||||
| self::stopProfiler(); | self::stopProfiler(); | ||||
| PhabricatorStartup::beginStartupPhase('profiler.done'); | |||||
| return self::$profileFilePHID; | return self::$profileFilePHID; | ||||
| } | } | ||||
| private static function stopProfiler() { | private static function stopProfiler() { | ||||
| if (!self::isProfilerRunning()) { | |||||
| return; | |||||
| } | |||||
| $data = xhprof_disable(); | $data = xhprof_disable(); | ||||
| $data = @json_encode($data); | $data = @json_encode($data); | ||||
| self::$profilerRunning = false; | self::$profilerRunning = false; | ||||
| // Since these happen on GET we can't do guarded writes. These also | // Since these happen on GET we can't do guarded writes. These also | ||||
| // sometimes happen after we've disposed of the write guard; in this | // sometimes happen after we've disposed of the write guard; in this | ||||
| // case we need to disable the whole mechanism. | // case we need to disable the whole mechanism. | ||||
| Show All 35 Lines | |||||