class TimeDataCollector in Devel 8.2
Same name and namespace in other branches
- 8.3 webprofiler/src/DataCollector/TimeDataCollector.php \Drupal\webprofiler\DataCollector\TimeDataCollector
- 8 webprofiler/src/DataCollector/TimeDataCollector.php \Drupal\webprofiler\DataCollector\TimeDataCollector
- 4.x webprofiler/src/DataCollector/TimeDataCollector.php \Drupal\webprofiler\DataCollector\TimeDataCollector
Class TimeDataCollector.
Hierarchy
- class \Drupal\webprofiler\DataCollector\TimeDataCollector extends \Symfony\Component\HttpKernel\DataCollector\TimeDataCollector implements DrupalDataCollectorInterface uses StringTranslationTrait
Expanded class hierarchy of TimeDataCollector
1 string reference to 'TimeDataCollector'
- webprofiler.services.yml in webprofiler/
webprofiler.services.yml - webprofiler/webprofiler.services.yml
1 service uses TimeDataCollector
File
- webprofiler/
src/ DataCollector/ TimeDataCollector.php, line 16
Namespace
Drupal\webprofiler\DataCollectorView source
class TimeDataCollector extends BaseTimeDataCollector implements DrupalDataCollectorInterface {
use StringTranslationTrait, DrupalDataCollectorTrait;
/**
* @param \Symfony\Component\HttpKernel\KernelInterface $kernel
* @param $stopwatch
*/
public function __construct(KernelInterface $kernel = NULL, $stopwatch = NULL) {
parent::__construct($kernel, $stopwatch);
}
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = NULL) {
parent::collect($request, $response, $exception);
$this->data['memory_limit'] = $this
->convertToBytes(ini_get('memory_limit'));
$this
->updateMemoryUsage();
}
/**
* {@inheritdoc}
*/
public function lateCollect() {
parent::lateCollect();
$this
->updateMemoryUsage();
}
/**
* Gets the memory.
*
* @return int
* The memory
*/
public function getMemory() {
return $this->data['memory'];
}
/**
* Gets the PHP memory limit.
*
* @return int
* The memory limit
*/
public function getMemoryLimit() {
return $this->data['memory_limit'];
}
/**
* Updates the memory usage data.
*/
public function updateMemoryUsage() {
$this->data['memory'] = memory_get_peak_usage(TRUE);
}
/**
* {@inheritdoc}
*/
public function getTitle() {
return $this
->t('Timeline');
}
/**
* {@inheritdoc}
*/
public function getPanelSummary() {
return $this
->t('Duration: @duration', [
'@duration' => sprintf('%.0f ms', $this
->getDuration()),
]);
}
/**
* {@inheritdoc}
*/
public function getIcon() {
return 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAcCAYAAABoMT8aAAABqUlEQVR42t2Vv0sCYRyHX9OmEhsMx/YKGlwLQ69DTEUSBJEQEy5J3FRc/BsuiFqEIIcQIRo6ysUhoaBBWhoaGoJwiMJLglRKrs8bXgienmkQdPDAwX2f57j3fhFJkkbiPwTK5bIiFoul3kmPud8MqKMewDXpwuGww+12n9hsNhFnlijYf/Z4PDmO45Yxo+10ZFGTyWRMEItU6AdCx7lczkgd6n7J2Wx2xm63P6jJMk6n80YQBBN1aUDv9XqvlAbbm2LE7/cLODRB0un0VveAeoDC8/waCQQC18MGQqHQOcEKvw8bcLlcL6TfYnVtCrGRAlartUUYhmn1jKg/E3USjUYfhw3E4/F7ks/nz4YNFIvFQ/ogbUYikdefyqlU6gnuOg2YK5XKvs/n+xhUDgaDTVEUt+HO04ABOBA5isViDTU5kUi81Wq1AzhWMEkDGmAEq2C3UCjcYXGauDvfEsuyUjKZbJRKpVvM8IABU9SVX+cxYABmwIE9cFqtVi9xtgvsC2AHbIAFoKey0gdlHEyDObAEWLACFsEsMALdIJ80+dK0bTS95v7+v/AJnis0eO906QwAAAAASUVORK5CYII=';
}
/**
* {@inheritdoc}
*/
public function getLibraries() {
return [
'webprofiler/timeline',
];
}
/**
* {@inheritdoc}
*/
public function getDrupalSettings() {
/** @var StopwatchEvent[] $collectedEvents */
$collectedEvents = $this
->getEvents();
if (!empty($collectedEvents)) {
$sectionPeriods = $collectedEvents['__section__']
->getPeriods();
$endTime = end($sectionPeriods)
->getEndTime();
$events = [];
foreach ($collectedEvents as $key => $collectedEvent) {
if ('__section__' != $key) {
$periods = [];
foreach ($collectedEvent
->getPeriods() as $period) {
$periods[] = [
'start' => sprintf("%F", $period
->getStartTime()),
'end' => sprintf("%F", $period
->getEndTime()),
];
}
$events[] = [
"name" => $key,
"category" => $collectedEvent
->getCategory(),
"origin" => sprintf("%F", $collectedEvent
->getOrigin()),
"starttime" => sprintf("%F", $collectedEvent
->getStartTime()),
"endtime" => sprintf("%F", $collectedEvent
->getEndTime()),
"duration" => sprintf("%F", $collectedEvent
->getDuration()),
"memory" => sprintf("%.1F", $collectedEvent
->getMemory() / 1024 / 1024),
"periods" => $periods,
];
}
}
return [
'time' => [
'events' => $events,
'endtime' => $endTime,
],
];
}
else {
return [
'time' => [
'events' => [],
'endtime' => 0,
],
];
}
}
/**
* @return array
*/
public function getData() {
$data = $this->data;
$data['duration'] = $this
->getDuration();
$data['initTime'] = $this
->getInitTime();
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDataCollectorInterface:: |
public | function | Returns the name of the collector. | 21 |
DrupalDataCollectorInterface:: |
public | function | Returns true if this datacollector has a detail panel. | 2 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TimeDataCollector:: |
public | function | Collects data for the given Request and Response. | |
TimeDataCollector:: |
public | function |
Overrides DrupalDataCollectorInterface:: |
|
TimeDataCollector:: |
public | function |
Overrides DrupalDataCollectorInterface:: |
|
TimeDataCollector:: |
public | function |
Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface:: |
|
TimeDataCollector:: |
public | function |
Returns the libraries needed in detail panel. Overrides DrupalDataCollectorInterface:: |
|
TimeDataCollector:: |
public | function | Gets the memory. | |
TimeDataCollector:: |
public | function | Gets the PHP memory limit. | |
TimeDataCollector:: |
public | function |
Returns the string used in vertical tab summary. Overrides DrupalDataCollectorInterface:: |
|
TimeDataCollector:: |
public | function |
Returns the datacollector title. Overrides DrupalDataCollectorInterface:: |
|
TimeDataCollector:: |
public | function | Collects data as late as possible. | |
TimeDataCollector:: |
public | function | Updates the memory usage data. | |
TimeDataCollector:: |
public | function |