function PerformanceDataCollector::destruct
Same name and namespace in other branches
- 11.x 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 62
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();
// This loop should be safe because we know a very finite number of requests
// will be trying to acquire a lock at any one time.
while (!$lock->acquire('performance_test')) {
$lock->wait();
}
$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.