本文整理汇总了PHP中Profiler::enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Profiler::enabled方法的具体用法?PHP Profiler::enabled怎么用?PHP Profiler::enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profiler
的用法示例。
在下文中一共展示了Profiler::enabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: InitProfiler
public function InitProfiler()
{
// If timing parameter is set, force the profiler to be on
$timing = any($this->request["args"]["timing"], $this->cfg->servers["profiler"]["level"], 0);
if (!empty($this->cfg->servers["profiler"]["percent"])) {
if (rand() % 100 < $this->cfg->servers["profiler"]["percent"]) {
$timing = 4;
Profiler::$log = true;
}
}
if (!empty($timing)) {
Profiler::$enabled = true;
Profiler::setLevel($timing);
}
}
示例2: disable
/**
* Disable the profiler
*
* @see profiler::enabled
*
* @return null doesn't return anything.
*/
public static function disable()
{
if (self::$currentNode == null && count(self::$topNodes) == 0) {
self::$enabled = false;
} else {
throw new exception("Can not disable profiling once it has begun.");
}
}
示例3: LoadServers
/**
* Load server settings from specified ini file
*
* @param string $cfgfile ini file to load from
* @return array server config block (also stored as $this->servers)
*/
function LoadServers($cfgfile, $assign = true)
{
//Profiler::StartTimer("ConfigManager::LoadServers()");
$servers = array();
$this->hostname = $hostname = php_uname("n");
if (file_exists($cfgfile)) {
$mtime = filemtime($cfgfile);
if (!empty($mtime)) {
// NOTE - This uses APC directly, since the datamanager object requires this function to execute before initializing
$apcenabled = ini_get("apc.enabled");
$apckey = "servers.ini.{$mtime}";
//print "check apc for '$apckey'<br />";
if ($apcenabled && ($apccontents = apc_fetch($apckey)) != false) {
//print "found in apc, unserialize ($apccontents)<br />";
$servers = unserialize($apccontents);
} else {
//print "not found in apc, parse it<br />";
$settings = parse_ini_file($cfgfile, true);
Logger::Info("Loading server config: {$hostname}");
// First load the defaults
if (!empty($settings["default"])) {
array_set_multi($servers, $settings["default"]);
}
// set the role
$servers["role"] = $settings["mapping"][$hostname] ? $settings["mapping"][$hostname] : "live";
// default to live so the site will work if hostname couldn't be determined
// If our host is part of a grouping, load those settings up
if (!empty($settings["mapping"]) && !empty($settings["mapping"][$hostname]) && !empty($settings[$settings["mapping"][$hostname]])) {
Logger::Info("{$hostname} is currently in the '" . $settings["mapping"][$hostname] . "' group");
array_set_multi($servers, $settings[$settings["mapping"][$hostname]]);
}
// And finally, load any host-specific settings
if (!empty($settings[$hostname])) {
array_set_multi($servers, $settings[$hostname]);
}
if ($apcenabled) {
apc_store($apckey, serialize($servers));
}
}
}
if ($assign) {
$this->servers =& $servers;
}
$this->current =& $this->servers;
//Profiler::StopTimer("ConfigManager::LoadServers()");
if (isset($this->servers["logger"]["enabled"]) && empty($this->servers["logger"]["enabled"])) {
Logger::$enabled = false;
}
if (isset($this->servers["profiler"]["enabled"]) && empty($this->servers["profiler"]["enabled"])) {
Profiler::$enabled = false;
}
}
// Update locations to reflect any new settings we got from the ini file
$this->locations = $this->getLocations();
// Merge any path settings from the config file into our environment
if (!empty($this->servers["elation"]["path"])) {
$elationpath = explode(":", $this->servers["elation"]["path"]);
$oldincludepath = get_include_path();
$includepath = explode(":", $oldincludepath);
$newincludepath = implode(":", array_merge(array_diff($elationpath, $includepath), $includepath));
if ($newincludepath != $oldincludepath) {
// set_include_path($newincludepath);
}
}
if (!empty($_COOKIE["tf-dev"])) {
$tfdev = json_decode($_COOKIE["tf-dev"], true);
if (!empty($tfdev["serveroverrides"])) {
$this->SetServerOverride($tfdev["serveroverrides"]);
}
}
return $servers;
}
示例4: LoadServers
/**
* Load server settings from specified ini file
*
* @param string $cfgfile ini file to load from
* @return array server config block (also stored as $this->servers)
*/
function LoadServers($assign = true)
{
//Profiler::StartTimer("ConfigManager::LoadServers()");
$servers = array();
// new method
$this->LoadSettings($this->locations["config"] . "/servers.ini");
$this->role = $this->GetRoleFromHostname();
$servers = array_merge_recursive_distinct($servers, $this->GetRoleSettings("default"));
$servers = array_merge_recursive_distinct($servers, $this->GetRoleSettings($this->role));
$this->locations = $this->getlocations();
// DISABLED - old method, had better caching of combined role config
/*
if (file_exists($cfgfile)) {
$mtime = filemtime($cfgfile);
if (!empty($mtime)) {
// NOTE - This uses APC directly, since the datamanager object requires this function to execute before initializing
$apckey = $cfgfile . "." . $mtime;
//print "check apc for '$apckey'<br />";
if ($this->apcenabled && ($apccontents = apc_fetch($apckey)) != false) {
//print "found in apc, unserialize ($apccontents)<br />";
$servers = unserialize($apccontents);
} else {
//print "not found in apc, parse it<br />";
$settings = parse_ini_file($cfgfile, true);
Logger::Info("Loading server config: $hostname");
// First load the defaults
if (!empty($settings["default"])) {
array_set_multi($servers, $settings["default"]);
}
// set the role
//$servers["role"] = ($settings["mapping"][$hostname]) ? $settings["mapping"][$hostname] : "live"; // default to live so the site will work if /etc/hostname is missing
// If our host is part of a grouping, load those settings up
if (!empty($settings["mapping"]) && !empty($settings["mapping"][$hostname]) && !empty($settings[$settings["mapping"][$hostname]])) {
Logger::Info("$hostname is currently in the '" . $settings["mapping"][$hostname] . "' group");
array_set_multi($servers, $settings[$settings["mapping"][$hostname]]);
}
// And finally, load any host-specific settings
if (!empty($settings[$hostname])) {
array_set_multi($servers, $settings[$hostname]);
}
if ($this->apcenabled) {
apc_store($apckey, serialize($servers));
}
}
}
}
*/
if ($assign) {
$this->servers =& $servers;
if (!empty($this->servers["role"])) {
// ini file specified overridden role
$this->role = $this->servers["role"];
}
}
//Profiler::StopTimer("ConfigManager::LoadServers()");
// set logger/profiler settings
if (isset($this->servers["logger"]["enabled"]) && empty($this->servers["logger"]["enabled"])) {
Logger::$enabled = false;
}
if (isset($this->servers["profiler"]["enabled"]) && empty($this->servers["profiler"]["enabled"])) {
Profiler::$enabled = false;
}
// Update locations to reflect any new settings we got from the ini file
$this->locations = $this->getLocations();
// Merge any path settings from the config file into our environment
if (!empty($this->servers["elation"]["path"])) {
$elationpath = explode(":", $this->servers["elation"]["path"]);
$oldincludepath = get_include_path();
$includepath = explode(":", $oldincludepath);
$newincludepath = implode(":", array_merge(array_diff($elationpath, $includepath), $includepath));
if ($newincludepath != $oldincludepath) {
// set_include_path($newincludepath);
}
}
// Merge any settings which are overridden by a dev cookie
if (!empty($_COOKIE["tf-dev"])) {
$tfdev = json_decode($_COOKIE["tf-dev"], true);
if (!empty($tfdev["serveroverrides"])) {
$this->SetServerOverride($tfdev["serveroverrides"]);
}
}
return $servers;
}