当前位置: 首页>>代码示例>>PHP>>正文


PHP opcache_get_status函数代码示例

本文整理汇总了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;
 }
开发者ID:anyatar,项目名称:Z-Ray-OPcache,代码行数:30,代码来源:OPcache.php

示例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);
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:25,代码来源:OPCacheInfo.php

示例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');
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:34,代码来源:PhabricatorOpcodeCacheSpec.php

示例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);
 }
开发者ID:ChrisWesterfield,项目名称:MJR.ONE-CP,代码行数:30,代码来源:OpcacheDataCollector.php

示例5: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     if (extension_loaded('Zend OPcache')) {
         $this->_opCacheStats = opcache_get_status();
         $this->_opCacheConfig = opcache_get_configuration();
     }
 }
开发者ID:unifiedarts,项目名称:Hackathon_MageMonitoring,代码行数:10,代码来源:Zendopcache.php

示例6: __construct

 public function __construct($get_scripts = FALSE)
 {
     $this->statusData = opcache_get_status($get_scripts);
     if ($get_scripts) {
         $this->scripts = $this->statusData['scripts'];
     }
 }
开发者ID:reload,项目名称:dockhub-testing,代码行数:7,代码来源:OPCacheStatus.php

示例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'];
 }
开发者ID:highestgoodlikewater,项目名称:yii2-toolbox,代码行数:12,代码来源:ServerConfig.php

示例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);
 }
开发者ID:ossistyle,项目名称:http-client-description,代码行数:13,代码来源:PhpFileLinterTrait.php

示例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;
 }
开发者ID:sandeepdwarkapuria,项目名称:dotkernel,代码行数:14,代码来源:OpCache.php

示例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);
 }
开发者ID:xinzhanguo,项目名称:simplephpmvc,代码行数:10,代码来源:Test.php

示例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'];
 }
开发者ID:Tacsiazuma,项目名称:GW_System,代码行数:10,代码来源:OpCache.php

示例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();
 }
开发者ID:atulhere,项目名称:zendPractice,代码行数:17,代码来源:OpCacheMemory.php

示例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();
     }
 }
开发者ID:omnilight,项目名称:yz2-admin,代码行数:12,代码来源:OpCacheDataModel.php

示例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;
 }
开发者ID:TicketSwap,项目名称:opcache-primer,代码行数:19,代码来源:Prime.php

示例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 ';';
             }
         }
     }
 }
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:14,代码来源:opcache.php


注:本文中的opcache_get_status函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。