本文整理汇总了PHP中opcache_get_status函数的典型用法代码示例。如果您正苦于以下问题:PHP opcache_get_status函数的具体用法?PHP opcache_get_status怎么用?PHP opcache_get_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了opcache_get_status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shutdown
public function shutdown($context, &$storage)
{
if ($this->shutdownCalled) {
return;
}
$this->shutdownCalled = true;
$status = opcache_get_status();
$config = opcache_get_configuration();
$storage['opMemoryUsage'][] = $status['memory_usage'];
$storage['opInternedStringsUsage'][] = $status['interned_strings_usage'];
$storage['opStatistics'][] = $status['opcache_statistics'];
$storage['opDirectives'][] = $config['directives'];
$storage['opVersion'][] = $config['version'];
$storage['opBlacklist'][] = $config['blacklist'];
$scripts = $status['scripts'];
array_walk($scripts, function (&$item, $key) {
$item = array_merge(array('name' => basename($item['full_path'])), array('Full Path' => $item['full_path']), $item);
$item['memory Consumption'] = round($item['memory_consumption'] / 1024) . " KB ({$item['memory_consumption']} B)";
$item['Last Used'] = $item['last_used'];
$item['Last Used Timestamp'] = $item['last_used_timestamp'];
$item['created'] = date("D M j G:i:s Y", $item['timestamp']);
$item['created Timestamp'] = $item['timestamp'];
unset($item['full_path']);
unset($item['memory_consumption']);
unset($item['last_used']);
unset($item['last_used_timestamp']);
unset($item['timestamp']);
});
$storage['opcacheScripts'] = $scripts;
}
示例2: renderLoadedFiles
public function renderLoadedFiles($tableName)
{
$status = opcache_get_status(true);
$loadedFiles = get_included_files();
$scriptInfo = array();
if (isset($status['scripts']) == false) {
return "Failed to load scripts info to generate OPCache info.";
}
foreach ($loadedFiles as $loadedFile) {
$newScriptInfo = array();
if (array_key_exists($loadedFile, $status['scripts']) == true) {
$newScriptInfo["memory_consumption"] = $status['scripts'][$loadedFile]["memory_consumption"];
$newScriptInfo["hits"] = $status['scripts'][$loadedFile]["hits"];
} else {
$newScriptInfo["memory_consumption"] = "-";
$newScriptInfo["hits"] = "-";
}
$newScriptInfo['path'] = $loadedFile;
if (mb_strpos($loadedFile, $this->root) === 0) {
$newScriptInfo['path'] = '.' . mb_substr($loadedFile, mb_strlen($this->root));
}
$scriptInfo[] = $newScriptInfo;
}
return $this->renderTable($tableName, $scriptInfo);
}
示例3: initOpcacheSpec
private function initOpcacheSpec()
{
$this->setName(pht('Zend OPcache'))->setVersion(phpversion('Zend OPcache'));
if (ini_get('opcache.enable')) {
$this->setIsEnabled(true)->setClearCacheCallback('opcache_reset');
$status = opcache_get_status();
$memory = $status['memory_usage'];
$mem_used = $memory['used_memory'];
$mem_free = $memory['free_memory'];
$mem_junk = $memory['wasted_memory'];
$this->setUsedMemory($mem_used + $mem_junk);
$this->setTotalMemory($mem_used + $mem_junk + $mem_free);
$this->setEntryCount($status['opcache_statistics']['num_cached_keys']);
$is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
$validate = ini_get('opcache.validate_timestamps');
$freq = ini_get('opcache.revalidate_freq');
if ($is_dev && (!$validate || $freq)) {
$summary = pht('OPcache is not configured properly for development.');
$message = pht('In development, OPcache should be configured to always reload ' . 'code so nothing needs to be restarted after making changes. To do ' . 'this, enable "%s" and set "%s" to 0.', 'opcache.validate_timestamps', 'opcache.revalidate_freq');
$this->newIssue('extension.opcache.devmode')->setShortName(pht('OPcache Config'))->setName(pht('OPCache Not Configured for Development'))->setSummary($summary)->setMessage($message)->addPHPConfig('opcache.validate_timestamps')->addPHPConfig('opcache.revalidate_freq')->addPhabricatorConfig('phabricator.developer-mode');
} else {
if (!$is_dev && $validate) {
$summary = pht('OPcache is not configured ideally for production.');
$message = pht('In production, OPcache should be configured to never ' . 'revalidate code. This will slightly improve performance. ' . 'To do this, disable "%s" in your PHP configuration.', 'opcache.validate_timestamps');
$this->newIssue('extension.opcache.production')->setShortName(pht('OPcache Config'))->setName(pht('OPcache Not Configured for Production'))->setSummary($summary)->setMessage($message)->addPHPConfig('opcache.validate_timestamps')->addPhabricatorConfig('phabricator.developer-mode');
}
}
} else {
$this->setIsEnabled(false);
$summary = pht('Enabling OPcache will dramatically improve performance.');
$message = pht('The PHP "Zend OPcache" extension is installed, but not enabled in ' . 'your PHP configuration. Enabling it will dramatically improve ' . 'Phabricator performance. Edit the "%s" setting to ' . 'enable the extension.', 'opcache.enable');
$this->newIssue('extension.opcache.enable')->setShortName(pht('OPcache Disabled'))->setName(pht('Zend OPcache Not Enabled'))->setSummary($summary)->setMessage($message)->addPHPConfig('opcache.enable');
}
}
示例4: collect
/**
* {@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);
}
示例5: __construct
/**
* Constructor
*/
public function __construct()
{
if (extension_loaded('Zend OPcache')) {
$this->_opCacheStats = opcache_get_status();
$this->_opCacheConfig = opcache_get_configuration();
}
}
示例6: __construct
public function __construct($get_scripts = FALSE)
{
$this->statusData = opcache_get_status($get_scripts);
if ($get_scripts) {
$this->scripts = $this->statusData['scripts'];
}
}
示例7: opCacheEnabled
/**
* Whether or not PHP-OPcache is loaded and enabled
* @return boolean true if loaded
*/
public static function opCacheEnabled()
{
if (!static::extOpCacheLoaded()) {
return false;
}
$status = opcache_get_status();
return $status['opcache_enabled'];
}
示例8: lintFile
/**
* @param string $path
*
* @return bool
*/
private function lintFile($path)
{
static $linter;
if (empty($linter)) {
$linter = !empty(opcache_get_status(false)['opcache_enabled']) ? [$this, 'opcacheLint'] : [$this, 'commandLineLint'];
}
return call_user_func($linter, $path);
}
示例9: status
/**
* Get OpCache status data
* @param void
* @access public
* @return array
*/
public function status()
{
$status = null;
if (function_exists('opcache_get_status')) {
$status = opcache_get_status();
}
return $status;
}
示例10: opcode
public function opcode()
{
$i = opcache_get_status();
var_dump($i);
$file = '/vagrant/simplephpmvc/Caches/test.php';
// $v = opcache_compile_file($file);
// var_dump($v);
// $v2 = opcache_is_script_cached($file);
var_dump($v2);
}
示例11: __construct
public function __construct()
{
if (!function_exists('opcache_compile_file')) {
throw new \Exception("The OpCache extension isn't available!");
}
$status = opcache_get_status(true);
$this->memory = $status['memory_usage'];
$this->statistics = $status['opcache_statistics'];
$this->scripts = $status['scripts'];
}
示例12: check
/**
* Perform the check
*
* @see \ZendDiagnostics\Check\CheckInterface::check() *
* @return Failure|Skip|Success|Warning
*/
public function check()
{
if (!function_exists('opcache_get_status')) {
return new Warning('Zend OPcache extension is not available');
}
$this->opCacheInfo = opcache_get_status(false);
if (!is_array($this->opCacheInfo) || !array_key_exists('memory_usage', $this->opCacheInfo)) {
return new Warning('Zend OPcache extension is not enabled in this environment');
}
return parent::check();
}
示例13: __construct
public function __construct()
{
if (!extension_loaded('Zend OPcache')) {
$this->_opcacheEnabled = false;
} else {
$this->_opcacheEnabled = true;
}
if ($this->_opcacheEnabled) {
$this->_configuration = opcache_get_configuration();
$this->_status = opcache_get_status();
}
}
示例14: doClean
/**
* Removes files from the opcache. This assumes that the files still
* exist on the instance in a previous checkout.
*
* @return int
*/
public function doClean()
{
$status = opcache_get_status(true);
$filter = new StaleFiles($status['scripts'], $this->path);
$files = $filter->filter();
foreach ($files as $file) {
$status = opcache_invalidate($file['full_path'], true);
if (false === $status) {
$this->log(sprintf('Could not validate "%s".', $file['full_path']), 'error');
}
}
return 0;
}
示例15: getStatusDataRows
public function getStatusDataRows()
{
$stats = opcache_get_status();
foreach ($stats as $key => $val) {
if (is_array($val)) {
foreach ($val as $k => $v) {
echo $k;
echo ':';
echo $v;
echo ';';
}
}
}
}