Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / console / plugin / DarkConsoleStartupPlugin.php
blob4cc166725fa3e20ac7b9f37747da344e8c5e6dd9
1 <?php
3 final class DarkConsoleStartupPlugin extends DarkConsolePlugin {
5 public function getName() {
6 return pht('Startup');
9 public function getDescription() {
10 return pht('Timing information about the startup sequence.');
13 /**
14 * @phutil-external-symbol class PhabricatorStartup
16 public function generateData() {
17 return PhabricatorStartup::getPhases();
20 public function renderPanel() {
21 $data = $this->getData();
23 // Compute the time offset and duration of each startup phase.
24 $prev_key = null;
25 $init = null;
26 $phases = array();
27 foreach ($data as $key => $value) {
28 if ($init === null) {
29 $init = $value;
32 $offset = (int)floor(1000 * ($value - $init));
34 $phases[$key] = array(
35 'time' => $value,
36 'offset' => $value - $init,
40 if ($prev_key !== null) {
41 $phases[$prev_key]['duration'] = $value - $phases[$prev_key]['time'];
43 $prev_key = $key;
46 // Render the phases.
47 $rows = array();
48 foreach ($phases as $key => $phase) {
49 $offset_ms = (int)floor(1000 * $phase['offset']);
51 if (isset($phase['duration'])) {
52 $duration_us = (int)floor(1000000 * $phase['duration']);
53 } else {
54 $duration_us = null;
57 $rows[] = array(
58 $key,
59 pht('+%s ms', new PhutilNumber($offset_ms)),
60 ($duration_us === null)
61 ? pht('-')
62 : pht('%s us', new PhutilNumber($duration_us)),
63 null,
67 return id(new AphrontTableView($rows))
68 ->setHeaders(
69 array(
70 pht('Phase'),
71 pht('Offset'),
72 pht('Duration'),
73 null,
75 ->setColumnClasses(
76 array(
77 '',
78 'n right',
79 'n right',
80 'wide',
81 ));