header('location: index.php'); exit; } if (isset($_REQUEST['performance'])) { check_ticket('admin-inc-performance'); } ask_ticket('admin-inc-performance'); $opcode_stats = TikiLib::lib('admin')->getOpcodeCacheStatus(); $stat_flag = $opcode_stats['stat_flag']; if ($stat_flag) { $smarty->assign('stat_flag', $stat_flag); } $opcode_cache = $opcode_stats['opcode_cache']; $smarty->assign('opcode_cache', $opcode_cache); $smarty->assign('opcode_stats', $opcode_stats); $txtUsed = tr('Used'); $txtAvailable = tr('Available'); $smarty->assign('memory_graph', $tikilib->httpScheme() . '://chart.googleapis.com/chart?' . http_build_query(array('cht' => 'p3', 'chs' => '250x100', 'chd' => "t:{$opcode_stats['memory_used']},{$opcode_stats['memory_avail']}", 'chl' => $txtUsed . '|' . $txtAvailable, 'chtt' => tr('Memory')), '', '&')); $txtHit = tr('Hit'); $txtMiss = tr('Miss'); $smarty->assign('hits_graph', $tikilib->httpScheme() . '://chart.googleapis.com/chart?' . http_build_query(array('cht' => 'p3', 'chs' => '250x100', 'chd' => "t:{$opcode_stats['hit_hit']},{$opcode_stats['hit_miss']}", 'chl' => $txtHit . '|' . $txtMiss, 'chtt' => tr('Cache')), '', '&')); // realpath_cache_size can make considerable difference on php performance apparently if (function_exists('realpath_cache_size')) { $rpcs_current = realpath_cache_size(); $rpcs_ini = ini_get('realpath_cache_size'); $rpc_ttl = ini_get('realpath_cache_ttl'); $smarty->assign('realpath_cache_size_current', $rpcs_current); $smarty->assign('realpath_cache_size_ini', $rpcs_ini); $smarty->assign('realpath_cache_ttl', $rpc_ttl); $smarty->assign('realpath_cache_size_percent', round($rpcs_current / TikiLib::lib('tiki')->return_bytes($rpcs_ini) * 100, 2)); }
public static function logCacheSize() { if (function_exists('realpath_cache_size')) { $realPathCacheSize = realpath_cache_size(); } else { $realPathCacheSize = 'unknown'; } return ' Real patch cache size: ' . $realPathCacheSize; }
<?php var_dump(realpath_cache_size());
define('APP_FILECACHE_PATH', APP_PATH . C_DS . 'Data' . C_DS . 'Cache' . C_DS); /** * 定义MAGIC_QUOTES_GPC * * @var boolean */ if (version_compare(PHP_VERSION, '5.3.0', '<')) { @set_magic_quotes_runtime(0); } define('MAGIC_QUOTES_GPC', function_exists('get_magic_quotes_gpc') ? get_magic_quotes_gpc() : false); /** * 读取realpath缓存大小 * * @var size */ define('REALPATH_CACHE_SIZE', function_exists('realpath_cache_size') ? realpath_cache_size() : 'unknown'); /** * 对象聚合函数 * * @param $key * @param $obj * @return object */ function Super($key = NULL, $obj = NULL) { static $objs = array(); if (!$key) { return $objs; } elseif (!$obj) { return isset($objs[$key]) ? $objs[$key] : NULL; } else {
/** * Get realpath cache size * * @return int */ public function realpathCacheSize() : int { return realpath_cache_size(); }
/** * Get realpath cache size * * Returns memory usage of cache in bytes for path given by require/include * Performance costs * * @return int */ public function getRealpathCacheSize() { return realpath_cache_size(); }
if (defined("USERID")) { $userid = USERID; } else if (in_array(CRON_PAGE, non_auth_pages())) { $userid = "[CRON]"; } else { $userid = ''; } if (is_array($lab_fields)) { foreach ($lab_fields AS $field_collection) { foreach ($field_collection AS $key => $val) { $chkd_fields_array[] = $key; } } $chkd_fields = "'" . implode("', '", array_unique($chkd_fields_array)) . "'"; } create_cdisc_download($table_name, $lang, $app_title, $userid, $user_rights, $chkd_fields, '', $project_id, $constants['DOMAIN'], $debug); } else { error_log("SQL INSERT FAILED: " . db_error() . "\n"); echo db_error() . "<br />"; } } else { error_log("TRUNCATE FAILED: " . db_error() . "\n"); echo db_error() . "<br />"; } } $timer['main_end'] = microtime(true); $init_time = benchmark_timing($timer); echo $init_time; d(memory_get_peak_usage(true)); d(realpath_cache_size()); d(realpath_cache_get());
$Data[] = [$Key, nl2br(wordwrap($Value))]; if (isset($Call['Requirements'][$Key])) { $Call['Output']['Content'][] = ['Type' => 'Block', 'Class' => 'alert alert-danger', 'Value' => '<strong>' . $Key . '</strong> = "' . $Call['Requirements'][$Key] . '"']; } } $Call['Output']['Content'][] = ['Type' => 'Table', 'Value' => $Data]; return $Call; }); setFn('Menu', function ($Call) { $VersionNumber = phpversion(); $Version = isset($Call['Versions'][$VersionNumber]) ? $Call['Versions'][$VersionNumber] : 'Untested'; return ['Count' => $VersionNumber, 'Status' => 'Stable' == $Version ? 'success' : 'warning']; }); setFn('Realpath.Cache', function ($Call) { // Thanks to samdark $Used = realpath_cache_size(); $Available = ini_get('realpath_cache_size'); $Char = strtolower(substr($Available, -1, 1)); $Available = substr($Available, 0, strlen($Available) - 1); switch ($Char) { case 'k': $Available *= 1024; break; case 'm': $Available *= 1024 * 1024; break; case 'g': $Available *= 1024 * 1024 * 1024; break; } $TTL = ini_get('realpath_cache_ttl');
// Change the incomming data if needed $_GET = __magic_quotes_gpc( $_GET ); $_POST = __magic_quotes_gpc( $_POST ); $_COOKIE = __magic_quotes_gpc( $_COOKIE ); $_ENV = __magic_quotes_gpc( $_ENV ); $_REQUEST = __magic_quotes_gpc( $_REQUEST ); } // end magic_quotes_gpc Hack */ $time_start = microtime(true); $paths = array(realpath(dirname(__FILE__)), realpath(dirname(__FILE__) . '/library'), get_include_path()); set_include_path(implode(PATH_SEPARATOR, $paths)); require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->setFallbackAutoloader(true); Tinebase_Autoloader::initialize($autoloader); Tinebase_Core::dispatchRequest(); // log profiling information $time_end = microtime(true); $time = $time_end - $time_start; if (function_exists('memory_get_peak_usage')) { $memory = memory_get_peak_usage(true); } else { $memory = memory_get_usage(true); } if (function_exists('realpath_cache_size')) { $realPathCacheSize = realpath_cache_size(); } else { $realPathCacheSize = 'unknown'; } Tinebase_Core::getLogger()->info('index.php (' . __LINE__ . ') TIME: ' . $time . ' seconds MEMORY: ' . $memory / 1024 / 1024 . ' MBytes REALPATHCACHESIZE: ' . $realPathCacheSize);
if (!empty($_SERVER['SERVER_NAME'])) { echo "<tr class=tr-0><td class=td-0>APC Host</td><td>{$_SERVER['SERVER_NAME']} {$host}</td></tr>\n"; } if (!empty($_SERVER['SERVER_SOFTWARE'])) { echo "<tr class=tr-1><td class=td-0>Server Software</td><td>{$_SERVER['SERVER_SOFTWARE']}</td></tr>\n"; } echo <<<EOB \t\t<tr class=tr-0><td class=td-0>Shared Memory</td><td>{$mem['num_seg']} Segment(s) with {$seg_size} <br/> ({$cache['memory_type']} memory, {$cache['locking_type']} locking) </td></tr> EOB; echo '<tr class=tr-1><td class=td-0>Start Time</td><td>', date(DATE_FORMAT, $cache['start_time']), '</td></tr>'; echo '<tr class=tr-0><td class=td-0>Uptime</td><td>', duration($cache['start_time']), '</td></tr>'; echo '<tr class=tr-1><td class=td-0>File Upload Support</td><td>', $cache['file_upload_progress'], '</td></tr>'; echo '<tr class=tr-0><td class=td-0>RealPath total cache </td><td>', ini_get("realpath_cache_size"), '</td></tr>'; echo '<tr class=tr-1><td class=td-0>Realpath used cache</td><td>', realpath_cache_size() . "B", '</td></tr>'; echo <<<EOB \t\t</tbody></table> \t\t</div> \t\t<div class="info div1"><h2>File Cache Information</h2> \t\t<table cellspacing=0><tbody> \t\t<tr class=tr-0><td class=td-0>Cached Files</td><td>{$number_files} ({$size_files})</td></tr> \t\t<tr class=tr-1><td class=td-0>Hits</td><td>{$cache['num_hits']}</td></tr> \t\t<tr class=tr-0><td class=td-0>Misses</td><td>{$cache['num_misses']}</td></tr> \t\t<tr class=tr-1><td class=td-0>Request Rate (hits, misses)</td><td>{$req_rate} cache requests/second</td></tr> \t\t<tr class=tr-0><td class=td-0>Hit Rate</td><td>{$hit_rate} cache requests/second</td></tr> \t\t<tr class=tr-1><td class=td-0>Miss Rate</td><td>{$miss_rate} cache requests/second</td></tr> \t\t<tr class=tr-0><td class=td-0>Insert Rate</td><td>{$insert_rate} cache requests/second</td></tr> \t\t<tr class=tr-1><td class=td-0>Cache full count</td><td>{$cache['expunges']}</td></tr> \t\t</tbody></table>
<?php /* * Copyright (C) 2014, SugarCRM Inc. * * This product is licensed by SugarCRM under the Apache License, Version 2.0 (the "License"). * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 */ printf("hostname is %s\n", gethostname()); printf("ini_get('open_basedir') is %s\n", ini_get('open_basedir')); printf("ini_get('realpath_cache_size') is %s\n", ini_get('realpath_cache_size')); printf("ini_get('basedir.open_basedir') is %s\n", ini_get('basedir.open_basedir')); printf("realpath_cache_size is %s\n", realpath_cache_size()); var_dump(realpath_cache_get());
<?php $tpl->setVariable('realpath_cache', array('available' => ini_get('realpath_cache_size'), 'used' => realpath_cache_size(), 'entries' => count(realpath_cache_get()), 'ttl' => ini_get('realpath_cache_ttl')));
/** * Get realpath cache remaining * @return int */ protected function _testRealpathRemaining() { $used = realpath_cache_size(); $ini = strtoupper(trim(ini_get('realpath_cache_size'))); if (strpos($ini, 'K')) { $all = (int) str_replace('K', '', $ini) * 1024; } else { if (strpos($ini, 'M')) { $all = (int) str_replace('M', '', $ini) * 1024 * 1024; } } $result = $all - $used; if ($result < 0) { return 0; } return $result; }