ubuntu下php5.5启用opcache缓存功能
admin
2023-07-03 16:04:26
0

   opcache,php自身集成的缓存功能。由于我的系统是ubuntu server系统,所以在安装的时候很简单,直接apt-get install 方式安装的php,而且安装的是php5.5的版本,所以系统是自带opcache的,不需要我们再重新安装。

  接下来要配置一下opcache

sudo vi /etc/php5/fpm/conf.d
; configuration for php ZendOpcache module
; priority=05
;zend_extension=opcache.so
opcache.enable=1
opcache.save_comments=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
opcode.caching=1
opcache.force_restart_timeout=3600
opcache.optimization_level=0xffffffff
opcache.optimization=1
opcache.use_cwd=0
opcache.revalidate_path=0
opcache.enable_file_override=0

  然后修改php.ini文件,在最后添加一行zend_extension=opcache.so

  重启php-fpm或者是nginx,我们可以看到在phpinfo的界面出现了zend opcache的配置信息

 

ubuntu下php5.5启用opcache缓存功能

ubuntu下php5.5启用opcache缓存功能

 好了,到这里我们的opcache已经开始启用了。当然,在上面配置中,可以在php.ini中不加最后一行内容,但是在opcache的配置文件中要把注释去掉,也可以。

  现在看起来还是很别扭,我们可以通过直观的图表形式展现出来

   

ubuntu下php5.5启用opcache缓存功能

ubuntu下php5.5启用opcache缓存功能

ubuntu下php5.5启用opcache缓存功能

 好吧,没发过附件,无法上传,好像格式不对,直接上代码吧,网上也有很多的,可以自行百度。

 op.php

 

 2,
    'used_memory_percentage_high_threshold' => 80,
    'used_memory_percentage_mid_threshold' => 60,
    'allow_invalidate' => true
);
$validPages = array('overview', 'files', 'reset', 'invalidate');
$page = (empty($_GET['page']) || !in_array($_GET['page'], $validPages)
    ? 'overview'
    : strtolower($_GET['page'])
);
if ($page == 'reset') {
    opcache_reset();
    header('Location: ?page=overview');
    exit;
}
if ($page == 'invalidate') {
    $file = (isset($_GET['file']) ? trim($_GET['file']) : null);
    if (!$settings['allow_invalidate'] || !function_exists('opcache_invalidate') || empty($file)) {
        header('Location: ?page=files&error=1');
        exit;
    }
    $success = (int)opcache_invalidate(urldecode($file), true);
    header("Location: ?page=files&success={$success}");
    exit;
}
$opcache_config = opcache_get_configuration();
$opcache_status = opcache_get_status();
$opcache_funcs  = get_extension_funcs('Zend OPcache');
if (!empty($opcache_status['scripts'])) {
    uasort($opcache_status['scripts'], function($a, $b) {
        return $a['hits'] < $b['hits'];
    });
}
function memsize($size, $precision = 3, $space = false)
{
    $i = 0;
    $val = array(' bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    while (($size / 1024) > 1) {
        $size /= 1024;
        ++$i;
    }
    return sprintf("%.{$precision}f%s%s",
    $size, (($space && $i) ? ' ' : ''), $val[$i]);
}
function rc($at = null)
{
    static $i = 0;
    if ($at !== null) {
        $i = $at;
    } else {
        echo (++$i % 2 ? 'even' : 'odd');
    }
}
$data = array_merge(
    $opcache_status['memory_usage'],
    $opcache_status['opcache_statistics'],
    array(
        'total_memory_size'       => memsize($opcache_config['directives']['opcache.memory_consumption']),
        'used_memory_percentage'  => round(100 * (
            ($opcache_status['memory_usage']['used_memory'] + $opcache_status['memory_usage']['wasted_memory'])
                / $opcache_config['directives']['opcache.memory_consumption'])),
        'hit_rate_percentage'     => round($opcache_status['opcache_statistics']['opcache_hit_rate']),
        'wasted_percentage'       => round($opcache_status['memory_usage']['current_wasted_percentage'], 2),
        'used_memory_size'        => memsize($opcache_status['memory_usage']['used_memory']),
        'free_memory_size'        => memsize($opcache_status['memory_usage']['free_memory']),
        'wasted_memory_size'      => memsize($opcache_status['memory_usage']['wasted_memory']),
        'files_cached'            => number_format($opcache_status['opcache_statistics']['num_cached_scripts']),
        'hits_size'               => number_format($opcache_status['opcache_statistics']['hits']),
        'miss_size'               => number_format($opcache_status['opcache_statistics']['misses']),
        'blacklist_miss_size'     => number_format($opcache_status['opcache_statistics']['blacklist_misses']),
        'num_cached_keys_size'    => number_format($opcache_status['opcache_statistics']['num_cached_keys']),
        'max_cached_keys_size'    => number_format($opcache_status['opcache_statistics']['max_cached_keys']),
    )
);
$threshold = '';
if ($data['used_memory_percentage'] >= $settings['used_memory_percentage_high_threshold']) {
    $threshold = ' high';
} elseif ($data['used_memory_percentage'] >= $settings['used_memory_percentage_mid_threshold']) {
    $threshold = ' mid';
}
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])
    && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
) {
    echo json_encode($data);
    exit;
}
$host = (function_exists('gethostname')
    ? gethostname()
    : (php_uname('n')
        ?: (empty($_SERVER['SERVER_NAME'])
            ? $_SERVER['HOST_NAME']
            : $_SERVER['SERVER_NAME']
        )
    )
);
?>



    
    
    
    
    


    
    
    

Overview

%
memory usage

%
hit rate

total memory:

used memory:

free memory:

wasted memory: (%)

number of cached files:

number of hits:

number of misses:

blacklist misses:

number of cached keys:

max cached keys:


Enable real-time update of stats

General info
Zend OPcache
PHP
Host
Server Software
Start time
Last reset never' : date_format(date_create("@{$data['last_restart_time']}"), 'Y-m-d H:i:s')); ?>
$v): ?>
Directives
true' : 'false') : (empty($v) ? 'no value' : $v)); ?>
Available functions

File usage

file cached

Script Details

' . DIRECTORY_SEPARATOR; echo join(DIRECTORY_SEPARATOR, array_slice($parts, 0, $settings['compress_path_threshold'])) . DIRECTORY_SEPARATOR; echo ''; echo join(DIRECTORY_SEPARATOR, array_slice($parts, $settings['compress_path_threshold'])); if (count($parts) > $settings['compress_path_threshold']) { echo DIRECTORY_SEPARATOR; } echo "{$base}"; } else { echo htmlentities($s['full_path'], ENT_COMPAT, 'UTF-8'); } ?>

Force file invalidation

hits: , memory:
last used:
has been invalidated

ocp.php

1 || php_sapi_name()=='cli' || empty($_SERVER['REMOTE_ADDR']) ) { die; }  // weak block against indirect access
$time=time();
define('CACHEPREFIX',function_exists('opcache_reset')?'opcache_':(function_exists('accelerator_reset')?'accelerator_':''));
if ( !empty($_GET['RESET']) ) {
    if ( function_exists(CACHEPREFIX.'reset') ) { call_user_func(CACHEPREFIX.'reset'); }
    header( 'Location: '.str_replace('?'.$_SERVER['QUERY_STRING'],'',$_SERVER['REQUEST_URI']) );
    exit;
}
if ( !empty($_GET['RECHECK']) ) {
    if ( function_exists(CACHEPREFIX.'invalidate') ) {
        $recheck=trim($_GET['RECHECK']); $files=call_user_func(CACHEPREFIX.'get_status');
        if (!empty($files['scripts'])) {
            foreach ($files['scripts'] as $file=>$value) {
                if ( $recheck==='1' || strpos($file,$recheck)===0 )  call_user_func(CACHEPREFIX.'invalidate',$file);
            }
        }
        header( 'Location: '.str_replace('?'.$_SERVER['QUERY_STRING'],'',$_SERVER['REQUEST_URI']) );
    } else { echo 'Sorry, this feature requires Zend Opcache newer than April 8th 2013'; }
    exit;
}
?>


    OCP - Opcache Control Panel
    




Opcache Control Panel

Opcache not detected?'; die; } if ( !empty($_GET['FILES']) ) { echo '

files cached

'; files_display(); echo '
'; exit; } if ( !(isset($_REQUEST['GRAPHS']) && !$_REQUEST['GRAPHS']) && CACHEPREFIX=='opcache_') { graphs_display(); if ( !empty($_REQUEST['GRAPHS']) ) { exit; } } ob_start(); phpinfo(8); $phpinfo = ob_get_contents(); ob_end_clean(); // some info is only available via phpinfo? sadly buffering capture has to be used if ( !preg_match( '/module\_Zend (Optimizer\+|OPcache).+?(\]*\>.+?\<\/table\>).+?(\]*\>.+?\<\/table\>)/s', $phpinfo, $opcache) ) { } // todo if ( function_exists(CACHEPREFIX.'get_configuration') ) { echo '

general

'; $configuration=call_user_func(CACHEPREFIX.'get_configuration'); } $host=function_exists('gethostname')?@gethostname():@php_uname('n'); if (empty($host)) { $host=empty($_SERVER['SERVER_NAME'])?$_SERVER['HOST_NAME']:$_SERVER['SERVER_NAME']; } $version=array('Host'=>$host); $version['PHP Version']='PHP '.(defined('PHP_VERSION')?PHP_VERSION:'???').' '.(defined('PHP_SAPI')?PHP_SAPI:'').' '.(defined('PHP_OS')?' '.PHP_OS:''); $version['Opcache Version']=empty($configuration['version']['version'])?'???':$configuration['version'][CACHEPREFIX.'product_name'].' '.$configuration['version']['version']; print_table($version); if ( !empty($opcache[2]) ) { echo preg_replace('/\\[^>]+\<\/td\>\[0-9\,\. ]+\<\/td\>\<\/tr\>/','',$opcache[2]); } if ( function_exists(CACHEPREFIX.'get_status') && $status=call_user_func(CACHEPREFIX.'get_status') ) { $uptime=array(); if ( !empty($status[CACHEPREFIX.'statistics']['start_time']) ) { $uptime['uptime']=time_since($time,$status[CACHEPREFIX.'statistics']['start_time'],1,''); } if ( !empty($status[CACHEPREFIX.'statistics']['last_restart_time']) ) { $uptime['last_restart']=time_since($time,$status[CACHEPREFIX.'statistics']['last_restart_time']); } if (!empty($uptime)) {print_table($uptime);} if ( !empty($status['cache_full']) ) { $status['memory_usage']['cache_full']=$status['cache_full']; } echo '

memory

'; print_table($status['memory_usage']); unset($status[CACHEPREFIX.'statistics']['start_time'],$status[CACHEPREFIX.'statistics']['last_restart_time']); echo '

statistics

'; print_table($status[CACHEPREFIX.'statistics']); } if ( empty($_GET['ALL']) ) { meta_display(); exit; } if ( !empty($configuration['blacklist']) ) { echo '

blacklist

'; print_table($configuration['blacklist']); } if ( !empty($opcache[3]) ) { echo '

runtime

'; echo $opcache[3]; } $name='zend opcache'; $functions=get_extension_funcs($name); if (!$functions) { $name='zend optimizer+'; $functions=get_extension_funcs($name); } if ($functions) { echo '

functions

'; print_table($functions); } else { $name=''; } $level=trim(CACHEPREFIX,'_').'.optimization_level'; if (isset($configuration['directives'][$level])) { echo '

optimization levels

'; $levelset=strrev(base_convert($configuration['directives'][$level], 10, 2)); $levels=array( 1=>'Constants subexpressions elimination (CSE) true, false, null, etc.
Optimize series of ADD_STRING / ADD_CHAR
Convert CAST(IS_BOOL,x) into BOOL(x)
Convert INIT_FCALL_BY_NAME + DO_FCALL_BY_NAME into DO_FCALL', 2=>'Convert constant operands to expected types
Convert conditional JMP with constant operands
Optimize static BRK and CONT', 3=>'Convert $a = $a + expr into $a += expr
Convert $a++ into ++$a
Optimize series of JMP', 4=>'PRINT and ECHO optimization (defunct)', 5=>'Block Optimization - most expensive pass
Performs many different optimization patterns based on control flow graph (CFG)', 9=>'Optimize register allocation (allows re-usage of temporary variables)', 10=>'Remove NOPs' ); echo ''; foreach ($levels as $pass=>$description) { $disabled=substr($levelset,$pass-1,1)!=='1' || $pass==4 ? ' white':''; echo ''; } echo '
PassDescription
'.$pass.''.$description.'
'; } if ( isset($_GET['DUMP']) ) { if ($name) { echo '

ini

'; print_table(ini_get_all($name,true)); } foreach ($configuration as $key=>$value) { echo '

',$key,'

'; print_table($configuration[$key]); } exit; } meta_display(); echo '
'; exit; function time_since($time,$original,$extended=0,$text='ago') { $time = $time - $original; $day = $extended? floor($time/86400) : round($time/86400,0); $amount=0; $unit=''; if ( $time < 86400) { if ( $time < 60) { $amount=$time; $unit='second'; } elseif ( $time < 3600) { $amount=floor($time/60); $unit='minute'; } else { $amount=floor($time/3600); $unit='hour'; } } elseif ( $day < 14) { $amount=$day; $unit='day'; } elseif ( $day < 56) { $amount=floor($day/7); $unit='week'; } elseif ( $day < 672) { $amount=floor($day/30); $unit='month'; } else { $amount=intval(2*($day/365))/2; $unit='year'; } if ( $amount!=1) {$unit.='s';} if ($extended && $time>60) { $text=' and '.time_since($time,$time<86400?($time<3600?$amount*60:$amount*3600):$day*86400,0,'').$text; } return $amount.' '.$unit.' '.$text; } function print_table($array,$headers=false) { if ( empty($array) || !is_array($array) ) {return;} echo ''; if (!empty($headers)) { if (!is_array($headers)) {$headers=array_keys(reset($array));} echo ''; foreach ($headers as $value) { echo ''; } echo ''; } foreach ($array as $key=>$value) { echo ''; if ( !is_numeric($key) ) { $key=ucwords(str_replace('_',' ',$key)); echo ''; if ( is_numeric($value) ) { if ( $value>1048576) { $value=round($value/1048576,1).'M'; } elseif ( is_float($value) ) { $value=round($value,1); } } } if ( is_array($value) ) { foreach ($value as $column) { echo ''; } echo ''; } else { echo ''; } } echo '
',$value,'
',$key,'',$column,'
',$value,'
'; } function files_display() { $status=call_user_func(CACHEPREFIX.'get_status'); if ( empty($status['scripts']) ) {return;} if ( isset($_GET['DUMP']) ) { print_table($status['scripts']); exit;} $time=time(); $sort=0; $nogroup=preg_replace('/\&?GROUP\=[\-0-9]+/','',$_SERVER['REQUEST_URI']); $nosort=preg_replace('/\&?SORT\=[\-0-9]+/','',$_SERVER['REQUEST_URI']); $group=empty($_GET['GROUP'])?0:intval($_GET['GROUP']); if ( $group<0 || $group>9) { $group=1;} $groupset=array_fill(0,9,''); $groupset[$group]=' class="b" '; echo '
ungroup | 1 | 2 | 3 | 4 | 5
'; if ( !$group ) { $files =& $status['scripts']; } else { $files=array(); foreach ($status['scripts'] as $data) { if ( preg_match('@^[/]([^/]+[/]){'.$group.'}@',$data['full_path'],$path) ) { if ( empty($files[$path[0]])) { $files[$path[0]]=array('full_path'=>'','files'=>0,'hits'=>0,'memory_consumption'=>0,'last_used_timestamp'=>'','timestamp'=>''); } $files[$path[0]]['full_path']=$path[0]; $files[$path[0]]['files']++; $files[$path[0]]['memory_consumption']+=$data['memory_consumption']; $files[$path[0]]['hits']+=$data['hits']; if ( $data['last_used_timestamp']>$files[$path[0]]['last_used_timestamp']) {$files[$path[0]]['last_used_timestamp']=$data['last_used_timestamp'];} if ( $data['timestamp']>$files[$path[0]]['timestamp']) {$files[$path[0]]['timestamp']=$data['timestamp'];} } } } if ( !empty($_GET['SORT']) ) { $keys=array( 'full_path'=>SORT_STRING, 'files'=>SORT_NUMERIC, 'memory_consumption'=>SORT_NUMERIC, 'hits'=>SORT_NUMERIC, 'last_used_timestamp'=>SORT_NUMERIC, 'timestamp'=>SORT_NUMERIC ); $titles=array('','path',$group?'files':'','size','hits','last used','created'); $offsets=array_keys($keys); $key=intval($_GET['SORT']); $direction=$key>0?1:-1; $key=abs($key)-1; $key=isset($offsets[$key])&&!($key==1&&empty($group))?$offsets[$key]:reset($offsets); $sort=array_search($key,$offsets)+1; $sortflip=range(0,7); $sortflip[$sort]=-$direction*$sort; if ( $keys[$key]==SORT_STRING) {$direction=-$direction; } $arrow=array_fill(0,7,''); $arrow[$sort]=$direction>0?' ▼':' ▲'; $direction=$direction>0?SORT_DESC:SORT_ASC; $column=array(); foreach ($files as $data) { $column[]=$data[$key]; } array_multisort($column, $keys[$key], $direction, $files); } echo ''; foreach ($titles as $column=>$title) { if ($title) echo ''; } echo ' '; foreach ($files as $data) { echo '', ($group?'':''), '', '', '', ''; } echo '
',$title,$arrow[$column],'
x',$data['full_path'],''.number_format($data['files']).'',number_format(round($data['memory_consumption']/1024)),'K',number_format($data['hits']),'',time_since($time,$data['last_used_timestamp']),'',empty($data['timestamp'])?'':time_since($time,$data['timestamp']),'
'; } function graphs_display() { $graphs=array(); $colors=array('green','brown','red'); $primes=array(223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987); $configuration=call_user_func(CACHEPREFIX.'get_configuration'); $status=call_user_func(CACHEPREFIX.'get_status'); $graphs['memory']['total']=$configuration['directives']['opcache.memory_consumption']; $graphs['memory']['free']=$status['memory_usage']['free_memory']; $graphs['memory']['used']=$status['memory_usage']['used_memory']; $graphs['memory']['wasted']=$status['memory_usage']['wasted_memory']; $graphs['keys']['total']=$status[CACHEPREFIX.'statistics']['max_cached_keys']; foreach ($primes as $prime) { if ($prime>=$graphs['keys']['total']) { $graphs['keys']['total']=$prime; break;} } $graphs['keys']['free']=$graphs['keys']['total']-$status[CACHEPREFIX.'statistics']['num_cached_keys']; $graphs['keys']['scripts']=$status[CACHEPREFIX.'statistics']['num_cached_scripts']; $graphs['keys']['wasted']=$status[CACHEPREFIX.'statistics']['num_cached_keys']-$status[CACHEPREFIX.'statistics']['num_cached_scripts']; $graphs['hits']['total']=0; $graphs['hits']['hits']=$status[CACHEPREFIX.'statistics']['hits']; $graphs['hits']['misses']=$status[CACHEPREFIX.'statistics']['misses']; $graphs['hits']['blacklist']=$status[CACHEPREFIX.'statistics']['blacklist_misses']; $graphs['hits']['total']=array_sum($graphs['hits']); $graphs['restarts']['total']=0; $graphs['restarts']['manual']=$status[CACHEPREFIX.'statistics']['manual_restarts']; $graphs['restarts']['keys']=$status[CACHEPREFIX.'statistics']['hash_restarts']; $graphs['restarts']['memory']=$status[CACHEPREFIX.'statistics']['oom_restarts']; $graphs['restarts']['total']=array_sum($graphs['restarts']); foreach ( $graphs as $caption=>$graph) { echo '
',$caption,'
'; foreach ($graph as $label=>$value) { if ($label=='total') { $key=0; $total=$value; $totaldisplay=''; continue;} $percent=$total?floor($value*100/$total):''; $percent=!$percent||$percent>99?'':$percent.'%'; echo '',$totaldisplay,''; $key++; $totaldisplay=''; } echo '
'.($total>999999?round($total/1024/1024).'M':($total>9999?round($total/1024).'K':$total)).'
', ($value>999999?round($value/1024/1024).'M':($value>9999?round($value/1024).'K':$value)),'',$percent,'',$label,'
',"\n"; } } function meta_display() { ?>

opcache.php

You do not have the Zend OPcache extension loaded, sample data is being shown instead.
'; require 'data-sample.php'; } class OpCacheDataModel { private $_configuration; private $_status; private $_d3Scripts = array(); public function __construct() { $this->_configuration = opcache_get_configuration(); $this->_status = opcache_get_status(); } public function getPageTitle() { return 'PHP ' . phpversion() . " with OpCache {$this->_configuration['version']['version']}"; } public function getStatusDataRows() { $rows = array(); foreach ($this->_status as $key => $value) { if ($key === 'scripts') { continue; } if (is_array($value)) { foreach ($value as $k => $v) { if ($v === false) { $value = 'false'; } if ($v === true) { $value = 'true'; } if ($k === 'used_memory' || $k === 'free_memory' || $k === 'wasted_memory') { $v = $this->_size_for_humans( $v ); } if ($k === 'current_wasted_percentage' || $k === 'opcache_hit_rate') { $v = number_format( $v, 2 ) . '%'; } if ($k === 'blacklist_miss_ratio') { $v = number_format($v, 2) . '%'; } if ($k === 'start_time' || $k === 'last_restart_time') { $v = ($v ? date(DATE_RFC822, $v) : 'never'); } $rows[] = "$k$v\n"; } continue; } if ($value === false) { $value = 'false'; } if ($value === true) { $value = 'true'; } $rows[] = "$key$value\n"; } return implode("\n", $rows); } public function getConfigDataRows() { $rows = array(); foreach ($this->_configuration['directives'] as $key => $value) { if ($value === false) { $value = 'false'; } if ($value === true) { $value = 'true'; } if ($key == 'opcache.memory_consumption') { $value = $this->_size_for_humans($value); } $rows[] = "$key$value\n"; } return implode("\n", $rows); } public function getScriptStatusRows() { foreach ($this->_status['scripts'] as $key => $data) { $dirs[dirname($key)][basename($key)] = $data; $this->_arrayPset($this->_d3Scripts, $key, array( 'name' => basename($key), 'size' => $data['memory_consumption'], )); } asort($dirs); $basename = ''; while (true) { if (count($this->_d3Scripts) !=1) break; $basename .= DIRECTORY_SEPARATOR . key($this->_d3Scripts); $this->_d3Scripts = reset($this->_d3Scripts); } $this->_d3Scripts = $this->_processPartition($this->_d3Scripts, $basename); $id = 1; $rows = array(); foreach ($dirs as $dir => $files) { $count = count($files); $file_plural = $count > 1 ? 's' : null; $m = 0; foreach ($files as $file => $data) { $m += $data["memory_consumption"]; } $m = $this->_size_for_humans($m); if ($count > 1) { $rows[] = ''; $rows[] = "{$dir} ({$count} file{$file_plural}, {$m})"; $rows[] = ''; } foreach ($files as $file => $data) { $rows[] = ""; $rows[] = "{$data["hits"]}"; $rows[] = "" . $this->_size_for_humans($data["memory_consumption"]) . ""; $rows[] = $count > 1 ? "{$file}" : "{$dir}/{$file}"; $rows[] = ''; } ++$id; } return implode("\n", $rows); } public function getScriptStatusCount() { return count($this->_status["scripts"]); } public function getGraphDataSetJson() { $dataset = array(); $dataset['memory'] = array( $this->_status['memory_usage']['used_memory'], $this->_status['memory_usage']['free_memory'], $this->_status['memory_usage']['wasted_memory'], ); $dataset['keys'] = array( $this->_status['opcache_statistics']['num_cached_keys'], $this->_status['opcache_statistics']['max_cached_keys'] - $this->_status['opcache_statistics']['num_cached_keys'], 0 ); $dataset['hits'] = array( $this->_status['opcache_statistics']['misses'], $this->_status['opcache_statistics']['hits'], 0, ); $dataset['restarts'] = array( $this->_status['opcache_statistics']['oom_restarts'], $this->_status['opcache_statistics']['manual_restarts'], $this->_status['opcache_statistics']['hash_restarts'], ); return json_encode($dataset); } public function getHumanUsedMemory() { return $this->_size_for_humans($this->getUsedMemory()); } public function getHumanFreeMemory() { return $this->_size_for_humans($this->getFreeMemory()); } public function getHumanWastedMemory() { return $this->_size_for_humans($this->getWastedMemory()); } public function getUsedMemory() { return $this->_status['memory_usage']['used_memory']; } public function getFreeMemory() { return $this->_status['memory_usage']['free_memory']; } public function getWastedMemory() { return $this->_status['memory_usage']['wasted_memory']; } public function getWastedMemoryPercentage() { return number_format($this->_status['memory_usage']['current_wasted_percentage'], 2); } public function getD3Scripts() { return $this->_d3Scripts; } private function _processPartition($value, $name = null) { if (array_key_exists('size', $value)) { return $value; } $array = array('name' => $name,'children' => array()); foreach ($value as $k => $v) { $array['children'][] = $this->_processPartition($v, $k); } return $array; } private function _size_for_humans($bytes) { if ($bytes > 1048576) { return sprintf('%.2f MB', $bytes / 1048576); } else { if ($bytes > 1024) { return sprintf('%.2f kB', $bytes / 1024); } else { return sprintf('%d bytes', $bytes); } } } // Borrowed from Laravel private function _arrayPset(&$array, $key, $value) { if (is_null($key)) return $array = $value; $keys = explode(DIRECTORY_SEPARATOR, ltrim($key, DIRECTORY_SEPARATOR)); while (count($keys) > 1) { $key = array_shift($keys); if ( ! isset($array[$key]) || ! is_array($array[$key])) { $array[$key] = array(); } $array =& $array[$key]; } $array[array_shift($keys)] = $value; return $array; } } $dataModel = new OpCacheDataModel(); ?> <?php echo $dataModel->getPageTitle(); ?>

getPageTitle(); ?>

getStatusDataRows(); ?>
getConfigDataRows(); ?>
getScriptStatusRows(); ?>
Hits Memory Path
✖ Close Visualisation


相关内容

热门资讯

花费半生积蓄,农村自建房热背后 今年以来,在安徽安庆望江县做外墙漆生意的徐仙琴越来越忙碌了,她和员工们每天奔波在县城的各个村庄里,找...
黎以冲突再升级对中东地区影响几... 从当前的局势来看,黎以双方博弈已陷入谈判停滞、战火升级的恶性循环,地区冲突风险持续走高。根据以军发布...
易事达取得载带冷却定型装置专利... 国家知识产权局信息显示,浙江易事达电子材料有限公司取得一项名为“一种载带冷却定型装置”的专利,授权公...
深度推荐:2026年五大精选手... 本文全面梳理2026年手机电池批发市场主流品牌,聚焦续航升级与库存优化两大核心需求。通过对五大头部品...
法国外长要求安理会就以色列在黎... △法国外长巴罗(资料图)当地时间5月31日,法国外长巴罗宣布,他已要求召开一次联合国安全理事会紧急会...
大数据赋能矿山安全 科技先锋刘... 在煤炭产业高质量发展与智慧矿山建设加速推进的背景下,矿山安全监管正从传统人工巡查向数字化、智能化、预...
解压玩具“娜塔莎”引争议,它的... 最近,一款名为“娜塔莎”的婴儿造型“捏捏乐”解压玩具在网络上和校园里悄然流行,商家宣称其可以用来缓解...
坚持“四个面向” 矢志科技报国... 5月30日,第十个全国科技工作者日如期而至。日前,中央宣传部、中国科协向全社会发布“最美科技工作者”...
显微镜的“能源革命” ——无液... 我国自主研制闭循环光耦合SPM系统,为量子科技前沿研究提供可持续的“中国方案”。 导读 Part ...
五部门开展“百场万企”大中小企... 记者从工业和信息化部获悉,工业和信息化部、国家发展改革委、国务院国资委等五部门联合印发通知,组织开展...