/** * {@inheritDoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { // This is needed to support the PHP 5.5 opcache as well as the old ZendOptimizer+-extension. if (function_exists('opcache_get_status')) { $status = opcache_get_status(); $config = opcache_get_configuration(); $version = $config['version']['opcache_product_name'] . ' ' . $config['version']['version']; $stats = $status['opcache_statistics']; $hitrate = $stats['opcache_hit_rate']; } elseif (function_exists('accelerator_get_status')) { $status = accelerator_get_status(); $config = accelerator_get_configuration(); $version = $config['version']['accelerator_product_name'] . ' ' . $config['version']['version']; $stats = $status['accelerator_statistics']; $hitrate = $stats['accelerator_hit_rate']; } $filelist = array(); if ($this->showFilelist) { foreach ($status['scripts'] as $key => $data) { $filelist[$key] = $data; $filelist[$key]['name'] = basename($key); } } // unset unneeded filelist to lower memory-usage unset($status['scripts']); $this->data = array('version' => $version, 'ini' => $config['directives'], 'filelist' => $filelist, 'status' => $status, 'stats' => $stats, 'hitrate' => $hitrate); }
function GetRecommendations() { $arResult = parent::GetRecommendations(); if (function_exists('accelerator_get_status')) { $is_ok = is_array(accelerator_get_status()); array_unshift($arResult, array("PARAMETER" => GetMessage("PERFMON_MEASURE_OPCODE_CACHING"), "IS_OK" => $is_ok, "VALUE" => $is_ok ? GetMessage("PERFMON_MEASURE_UP_AND_RUNNING") : GetMessage("PERFMON_MEASURE_DISABLED"), "RECOMMENDATION" => "")); } return $arResult; }
/** * Gets content panel for the Debugbar * * @return string */ public function getPanel() { $panel = ''; # Support for Zend Optimizer+ if (ini_get('zend_optimizerplus.enable')) { $infos = accelerator_get_status(); // print_r( accelerator_get_status()); $mem_size = $infos['memory_usage']['used_memory'] + $infos['memory_usage']['free_memory']; $mem_avail = $infos['memory_usage']['free_memory']; $mem_used = $infos['memory_usage']['used_memory']; $panel .= '<h4>APC/Zend_Optimizer+ activé </h4>'; $panel .= round($mem_avail / 1024 / 1024, 1) . 'Mo disponibles, ' . round($mem_used / 1024 / 1024, 1) . 'Mo utilisés<br />'; $panel .= $infos['accelerator_statistics']['num_cached_scripts'] . ' fichiers en cache / ' . $infos['accelerator_statistics']['max_cached_scripts'] . ' Max.<br />'; $panel .= $infos['accelerator_statistics']['hits'] . ' Hits (' . round($infos['accelerator_statistics']['accelerator_hit_rate'], 2) . '%)<br />'; } # Support for APC // if (function_exists('apc_sma_info') && ini_get('apc.enabled')) { // $mem = apc_sma_info(); // $mem_size = $mem['num_seg']*$mem['seg_size']; // $mem_avail = $mem['avail_mem']; // $mem_used = $mem_size-$mem_avail; // // $cache = apc_cache_info(); // // $panel .= '<h4>APC '.phpversion('apc').' Enabled</h4>'; // $panel .= round($mem_avail/1024/1024, 1).'M available, '.round($mem_used/1024/1024, 1).'M used'.$this->getLinebreak() // . @$cache['num_entries'].' Files cached ('.round($cache['mem_size']/1024/1024, 1).'M)'.$this->getLinebreak() // . $cache['num_hits'].' Hits ('.round($cache['num_hits'] * 100 / ($cache['num_hits']+$cache['num_misses']), 1).'%)'.$this->getLinebreak() // . $cache['expunges'].' Expunges (cache full count)'; // } foreach ($this->_cacheBackends as $name => $backend) { $fillingPercentage = $backend->getFillingPercentage(); $ids = $backend->getIds(); # Print full class name, backends might be custom $panel .= '<h4>Cache ' . $name . ' (' . get_class($backend) . ')</h4>'; $panel .= count($ids) . ' Entr' . (count($ids) > 1 ? 'ies' : 'y') . '' . $this->getLinebreak() . 'Filling Percentage: ' . $backend->getFillingPercentage() . '%' . $this->getLinebreak(); $cacheSize = 0; foreach ($ids as $id) { # Calculate valid cache size $mem_pre = memory_get_usage(); if ($cached = $backend->load($id)) { $mem_post = memory_get_usage(); $cacheSize += $mem_post - $mem_pre; unset($cached); } } $panel .= 'Valid Cache Size: ' . round($cacheSize / 1024, 1) . 'K'; } return $panel; }