Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/console/plugin/DarkConsoleStartupPlugin.php
13402 views
1
<?php
2
3
final class DarkConsoleStartupPlugin extends DarkConsolePlugin {
4
5
public function getName() {
6
return pht('Startup');
7
}
8
9
public function getDescription() {
10
return pht('Timing information about the startup sequence.');
11
}
12
13
/**
14
* @phutil-external-symbol class PhabricatorStartup
15
*/
16
public function generateData() {
17
return PhabricatorStartup::getPhases();
18
}
19
20
public function renderPanel() {
21
$data = $this->getData();
22
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;
30
}
31
32
$offset = (int)floor(1000 * ($value - $init));
33
34
$phases[$key] = array(
35
'time' => $value,
36
'offset' => $value - $init,
37
);
38
39
40
if ($prev_key !== null) {
41
$phases[$prev_key]['duration'] = $value - $phases[$prev_key]['time'];
42
}
43
$prev_key = $key;
44
}
45
46
// Render the phases.
47
$rows = array();
48
foreach ($phases as $key => $phase) {
49
$offset_ms = (int)floor(1000 * $phase['offset']);
50
51
if (isset($phase['duration'])) {
52
$duration_us = (int)floor(1000000 * $phase['duration']);
53
} else {
54
$duration_us = null;
55
}
56
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,
64
);
65
}
66
67
return id(new AphrontTableView($rows))
68
->setHeaders(
69
array(
70
pht('Phase'),
71
pht('Offset'),
72
pht('Duration'),
73
null,
74
))
75
->setColumnClasses(
76
array(
77
'',
78
'n right',
79
'n right',
80
'wide',
81
));
82
}
83
84
}
85
86