mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 11:22:40 +01:00
7b6c320e15
Summary: Ref T6930. This application collects and displays performance samples -- roughly, things Phabricator spent some kind of resource on. It will collect samples on different types of resources and events: - Wall time (queries, service calls, pages) - Bytes In / Bytes Out (requests) - Implicit requests to CSS/JS (static resources) I've started with the simplest case (static resources), since this can be used in an immediate, straghtforward way to improve packaging (look at which individual files have the most requests recently). There's no aggregation yet and a lot of the data isn't collected properly. Future diffs will add more dimension data (controllers, users), more event and resource types (queries, service calls, wall time), and more display options (aggregation, sorting). Test Plan: {F389344} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6930 Differential Revision: https://secure.phabricator.com/D12623
70 lines
1.9 KiB
PHP
70 lines
1.9 KiB
PHP
<?php
|
|
|
|
abstract class MultimeterController extends PhabricatorController {
|
|
|
|
private $dimensions = array();
|
|
|
|
protected function loadDimensions(array $rows) {
|
|
if (!$rows) {
|
|
return;
|
|
}
|
|
|
|
$map = array(
|
|
'eventLabelID' => new MultimeterLabel(),
|
|
'eventViewerID' => new MultimeterViewer(),
|
|
'eventHostID' => new MultimeterHost(),
|
|
'eventContextID' => new MultimeterContext(),
|
|
);
|
|
|
|
$ids = array();
|
|
foreach ($map as $key => $object) {
|
|
foreach ($rows as $row) {
|
|
$ids[$key][] = $row[$key];
|
|
}
|
|
}
|
|
|
|
foreach ($ids as $key => $list) {
|
|
$object = $map[$key];
|
|
if (empty($this->dimensions[$key])) {
|
|
$this->dimensions[$key] = array();
|
|
}
|
|
$this->dimensions[$key] += $object->loadAllWhere(
|
|
'id IN (%Ld)',
|
|
$list);
|
|
}
|
|
}
|
|
|
|
protected function getLabelDimension($id) {
|
|
if (empty($this->dimensions['eventLabelID'][$id])) {
|
|
return $this->newMissingDimension(new MultimeterLabel(), $id);
|
|
}
|
|
return $this->dimensions['eventLabelID'][$id];
|
|
}
|
|
|
|
protected function getViewerDimension($id) {
|
|
if (empty($this->dimensions['eventViewerID'][$id])) {
|
|
return $this->newMissingDimension(new MultimeterViewer(), $id);
|
|
}
|
|
return $this->dimensions['eventViewerID'][$id];
|
|
}
|
|
|
|
protected function getHostDimension($id) {
|
|
if (empty($this->dimensions['eventHostID'][$id])) {
|
|
return $this->newMissingDimension(new MultimeterHost(), $id);
|
|
}
|
|
return $this->dimensions['eventHostID'][$id];
|
|
}
|
|
|
|
protected function getContextDimension($id) {
|
|
if (empty($this->dimensions['eventContextID'][$id])) {
|
|
return $this->newMissingDimension(new MultimeterContext(), $id);
|
|
}
|
|
return $this->dimensions['eventContextID'][$id];
|
|
}
|
|
|
|
private function newMissingDimension(MultimeterDimension $dim, $id) {
|
|
$dim->setName('<missing:'.$id.'>');
|
|
return $dim;
|
|
}
|
|
|
|
}
|