function PerformanceDataCollector::destruct
Same name and namespace in other branches
- 10 core/modules/system/tests/modules/performance_test/src/PerformanceDataCollector.php \Drupal\performance_test\PerformanceDataCollector::destruct()
Overrides DestructableInterface::destruct
File
-
core/
modules/ system/ tests/ modules/ performance_test/ src/ PerformanceDataCollector.php, line 65
Class
Namespace
Drupal\performance_testCode
public function destruct() : void {
// Get the events now before issuing any more database queries so that this
// logging does not become part of the recorded data.
$database_events = $this->databaseEvents;
// Deliberately do not use an injected key value or lock service to avoid
// any overhead up until this point.
$lock = \Drupal::lock();
// There are a finite number of requests, so if we don't get the lock just
// wait for up to ten seconds then record the data anyway.
if (!$lock->acquire('performance_test')) {
$lock->wait('performance_test', 10);
}
$collection = \Drupal::keyValue('performance_test');
$existing_data = $collection->get('performance_test_data') ?? [
'database_events' => [],
'cache_operations' => [],
'cache_tag_operations' => [],
];
$existing_data['database_events'] = array_merge($existing_data['database_events'], $database_events);
$existing_data['cache_operations'] = array_merge($existing_data['cache_operations'], $this->cacheOperations);
$existing_data['cache_tag_operations'] = array_merge($existing_data['cache_tag_operations'], $this->cacheTagOperations);
$collection->set('performance_test_data', $existing_data);
$lock->release('performance_test');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.