public function w3tc_usage_statistics_summary_from_history($summary, $history)
 {
     $php_memory_100kb = Util_UsageStatistics::sum($history, 'php_memory_100kb');
     $php_requests = Util_UsageStatistics::sum($history, 'php_requests');
     if ($php_requests > 0) {
         $summary['php'] = array('memory' => Util_UsageStatistics::bytes_to_size($php_memory_100kb / $php_requests * 1024 * 10.24));
         $summary['php']['wp_requests_total'] = Util_UsageStatistics::integer($php_requests);
         $summary['php']['wp_requests_per_second'] = Util_UsageStatistics::value_per_period_seconds($php_requests, $summary);
     }
     return $summary;
 }
 public function w3tc_usage_statistics_summary_from_history($summary, $history)
 {
     // memcached servers
     $c = Dispatcher::config();
     if ($c->get_string('dbcache.engine') == 'memcached') {
         $summary['memcached_servers']['dbcache'] = array('servers' => $c->get_array('dbcache.memcached.servers'), 'username' => $c->get_boolean('dbcache.memcached.username'), 'password' => $c->get_boolean('dbcache.memcached.password'), 'name' => __('Database Cache', 'w3-total-cache'));
     } elseif ($c->get_string('dbcache.engine') == 'redis') {
         $summary['redis_servers']['dbcache'] = array('servers' => $c->get_array('dbcache.redis.servers'), 'username' => $c->get_boolean('dbcache.redis.username'), 'dbid' => $c->get_boolean('dbcache.redis.dbid'), 'password' => $c->get_boolean('dbcache.redis.password'), 'name' => __('Database Cache', 'w3-total-cache'));
     }
     // counters
     $dbcache_calls_total = Util_UsageStatistics::sum($history, 'dbcache_calls_total');
     $dbcache_calls_hits = Util_UsageStatistics::sum($history, 'dbcache_calls_hits');
     $summary['dbcache'] = array('calls_total' => Util_UsageStatistics::integer($dbcache_calls_total), 'calls_per_second' => Util_UsageStatistics::value_per_period_seconds($dbcache_calls_total, $summary), 'hit_rate' => Util_UsageStatistics::percent($dbcache_calls_total, $dbcache_calls_total));
     return $summary;
 }
 public function w3tc_usage_statistics_summary_from_history($summary, $history)
 {
     // memcached servers
     if ($this->_config->get_string('pgcache.engine') == 'memcached') {
         $summary['memcached_servers']['pgcache'] = array('servers' => $this->_config->get_array('pgcache.memcached.servers'), 'username' => $this->_config->get_boolean('pgcache.memcached.username'), 'password' => $this->_config->get_boolean('pgcache.memcached.password'), 'name' => __('Page Cache', 'w3-total-cache'));
     } elseif ($this->_config->get_string('pgcache.engine') == 'redis') {
         $summary['redis_servers']['pgcache'] = array('servers' => $this->_config->get_array('pgcache.redis.servers'), 'username' => $this->_config->get_boolean('pgcache.redis.username'), 'dbid' => $this->_config->get_boolean('pgcache.redis.dbid'), 'password' => $this->_config->get_boolean('pgcache.redis.password'), 'name' => __('Page Cache', 'w3-total-cache'));
     }
     // total size
     $g = Dispatcher::component('PgCache_ContentGrabber');
     $pagecache = array();
     $e = $this->_config->get_string('pgcache.engine');
     $pagecache['size_visible'] = $e == 'file_generic';
     $pagecache['requests_visible'] = $e != 'file_generic';
     if (isset($summary['period']['timestamp_end'])) {
         // need to return cache size
         if ($pagecache['size_visible']) {
             list($v, $should_count) = Util_UsageStatistics::get_or_init_size_transient('w3tc_ustats_pagecache_size', $summary);
             if ($should_count) {
                 $size = $g->get_cache_stats_size($summary['timeout_time']);
                 $v['size_used'] = Util_UsageStatistics::bytes_to_size2($size, 'bytes');
                 $v['items'] = Util_UsageStatistics::integer2($size, 'items');
                 set_transient('w3tc_ustats_pagecache_size', $v, 120);
             }
             if (isset($v['size_used'])) {
                 $pagecache['size_used'] = $v['size_used'];
                 $pagecache['items'] = $v['items'];
             }
         }
         // counters
         $requests_total = Util_UsageStatistics::sum($history, 'pagecache_requests_total');
         $requests_time_ms = Util_UsageStatistics::sum($history, 'pagecache_requests_time_10ms') * 10;
         $requests_hits = Util_UsageStatistics::sum($history, 'pagecache_requests_hits');
         $pagecache['requests_total'] = Util_UsageStatistics::integer($requests_total);
         $pagecache['request_time_ms'] = Util_UsageStatistics::value_per_period_seconds($requests_time_ms, $summary);
         $pagecache['requests_per_second'] = Util_UsageStatistics::value_per_period_seconds($requests_total, $summary);
         $pagecache['hit_rate'] = Util_UsageStatistics::percent($requests_hits, $requests_total);
     }
     $summary['pagecache'] = $pagecache;
     return $summary;
 }
 public function w3tc_usage_statistics_summary_from_history($summary, $history)
 {
     // memcached servers
     $c = Dispatcher::config();
     if ($c->get_string('minify.engine') == 'memcached') {
         $summary['memcached_servers']['minify'] = array('servers' => $c->get_array('minify.memcached.servers'), 'username' => $c->get_boolean('minify.memcached.username'), 'password' => $c->get_boolean('minify.memcached.password'), 'name' => __('Minification', 'w3-total-cache'));
     } elseif ($c->get_string('minify.engine') == 'redis') {
         $summary['redis_servers']['minify'] = array('servers' => $c->get_array('minify.redis.servers'), 'username' => $c->get_boolean('minify.redis.username'), 'dbid' => $c->get_boolean('minify.redis.dbid'), 'password' => $c->get_boolean('minify.redis.password'), 'name' => __('Minification', 'w3-total-cache'));
     }
     $e = $this->_config->get_string('minify.engine');
     $a = array('size_visible' => $e == 'file', 'requests_visible' => !($e == 'file' && $this->_config->get_boolean('minify.rewrite')));
     if (!isset($summary['period']['timestamp_end'])) {
         // summary requested, enough
         $summary['minify'] = $a;
         return $summary;
     }
     // get requests rate stats
     if ($a['requests_visible']) {
         // counters
         $requests_total = Util_UsageStatistics::sum($history, 'minify_requests_total');
         $original_length_css = Util_UsageStatistics::sum($history, 'minify_original_length_css');
         $output_length_css = Util_UsageStatistics::sum($history, 'minify_output_length_css');
         $original_length_js = Util_UsageStatistics::sum($history, 'minify_original_length_js');
         $output_length_js = Util_UsageStatistics::sum($history, 'minify_output_length_js');
         $a['requests_total'] = Util_UsageStatistics::integer($requests_total);
         $a['requests_per_second'] = Util_UsageStatistics::value_per_period_seconds($requests_total, $summary);
         $a['compression_css'] = Util_UsageStatistics::percent($original_length_css - $output_length_css, $original_length_css);
         $a['compression_js'] = Util_UsageStatistics::percent($original_length_js - $output_length_js, $original_length_js);
     }
     if ($a['size_visible']) {
         list($v, $should_count) = Util_UsageStatistics::get_or_init_size_transient('w3tc_ustats_minify_size', $summary);
         if ($should_count || true) {
             $h = Dispatcher::component('Minify_MinifiedFileRequestHandler');
             $stats = $h->get_stats_size($summary['timeout_time']);
             // build stats to show
             $v['size_used'] = Util_UsageStatistics::bytes_to_size($stats['css']['output_length'] + $stats['js']['output_length']);
             $v['size_items'] = Util_UsageStatistics::integer($stats['css']['items'] + $stats['js']['items']);
             $v['size_compression_css'] = Util_UsageStatistics::percent($stats['css']['original_length'] - $stats['css']['output_length'], $stats['css']['original_length']);
             $v['size_compression_js'] = Util_UsageStatistics::percent($stats['js']['original_length'] - $stats['js']['output_length'], $stats['js']['original_length']);
             set_transient('w3tc_ustats_pagecache_size', $v, 120);
         }
         if (isset($v['size_used'])) {
             $a['size_used'] = $v['size_used'];
             $a['size_items'] = $v['size_items'];
             $a['size_compression_css'] = $v['size_compression_css'];
             $a['size_compression_js'] = $v['size_compression_js'];
         }
     }
     $summary['minify'] = $a;
     return $summary;
 }