public static function DrupalMemcachedDebug::getSummaryLogTable in Memcache Storage 8
Returns table element with summary debug information about all memcached transactions.
Return value
array|bool
1 call to DrupalMemcachedDebug::getSummaryLogTable()
- memcache_storage_page_bottom in ./
memcache_storage.module - Implements hook_page_bottom().
File
- src/
DrupalMemcachedDebug.php, line 33
Class
- DrupalMemcachedDebug
- Class DrupalMemcachedDebug @package Drupal\memcache_storage
Namespace
Drupal\memcache_storageCode
public static function getSummaryLogTable() {
if (empty(self::$log)) {
return FALSE;
}
$common_stats = [];
foreach (self::$log as $key => $entry) {
$operation = $entry['operation'];
if (empty($common_stats[$operation])) {
$common_stats[$operation]['operation'] = $operation;
$common_stats[$operation]['time'] = 0;
$common_stats[$operation]['hit'] = 0;
$common_stats[$operation]['miss'] = 0;
}
$status = !empty($entry['result']) ? 'hit' : 'miss';
$common_stats[$operation][$status]++;
// Do not collect statistics if previos row is same as current.
if (isset(self::$log[$key - 1]) && self::$log[$key - 1]['used_time'] == $entry['used_time'] && self::$log[$key - 1]['operation'] == $entry['operation'] && strpos($entry['operation'], 'Multi') !== FALSE) {
continue;
}
$common_stats[$operation]['time'] += $entry['used_time'];
}
foreach ($common_stats as &$stats) {
$stats['hit'] = $stats['hit'] . ' / ' . number_format($stats['hit'] / ($stats['hit'] + $stats['miss']) * 100, 1) . '%';
$stats['miss'] = $stats['miss'] . ' / ' . number_format($stats['miss'] / ($stats['hit'] + $stats['miss']) * 100, 1) . '%';
}
return [
'#type' => 'table',
'#header' => [
t('Action'),
t('Total time, ms'),
t('Total hits / %'),
t('Total misses / %'),
],
'#rows' => $common_stats,
'#attributes' => [
'id' => 'memcache-storage-common-debug',
],
'#attached' => [
'library' => [
'memcache_storage/debug-table',
],
],
];
}