@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 84 lines 1.8 kB view raw
1<?php 2 3final 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}