本文整理汇总了PHP中xhprof_error函数的典型用法代码示例。如果您正苦于以下问题:PHP xhprof_error函数的具体用法?PHP xhprof_error怎么用?PHP xhprof_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xhprof_error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
public function connect()
{
$this->linkID = mysqli_connect($this->config['dbhost'], $this->config['dbuser'], $this->config['dbpass'], $this->config['dbname']);
if ($this->linkID === FALSE) {
xhprof_error("Could not connect to db");
throw new Exception("Unable to connect to database");
return false;
}
$this->query("SET NAMES utf8");
}
示例2: connect
public function connect()
{
$linkid = mssql_connect($this->config['dbhost'], $this->config['dbuser'], $this->config['dbpass']);
if ($linkid === FALSE) {
xhprof_error("Could not connect to db");
throw new Exception("Unable to connect to database");
return false;
}
mssql_select_db($this->config['dbname'], $linkid);
$this->linkID = $linkid;
}
示例3: xhprof_http_header
/**
* Send an HTTP header with the response. You MUST use this function instead
* of header() so that we can debug header issues because they're virtually
* impossible to debug otherwise. If you try to commit header(), SVN will
* reject your commit.
*
* @param string HTTP header name, like 'Location'
* @param string HTTP header value, like 'http://www.example.com/'
*
*/
function xhprof_http_header($name, $value)
{
if (!$name) {
xhprof_error('http_header usage');
return null;
}
if (!is_string($value)) {
xhprof_error('http_header value not a string');
}
header($name . ': ' . $value, true);
}
示例4: connect
public function connect()
{
$connectionInfo = array("UID" => $this->config['dbuser'], "PWD" => $this->config['dbpass'], "Database" => $this->config['dbname'], "ReturnDatesAsStrings" => TRUE);
$linkid = sqlsrv_connect($this->config['dbhost'], $connectionInfo);
if ($linkid === FALSE) {
xhprof_error("Could not connect to db");
throw new Exception("Unable to connect to database");
return false;
}
$this->linkID = $linkid;
}
示例5: db
protected function db()
{
global $_xhprof;
$linkid = mysqli_connect($_xhprof['dbhost'], $_xhprof['dbuser'], $_xhprof['dbpass']);
if ($linkid === FALSE) {
xhprof_error("Could not connect to db");
$run_desc = "could not connect to db";
throw new Exception("Unable to connect to database");
return false;
}
mysqli_select_db($linkid, $_xhprof['dbname']);
$this->linkID = $linkid;
}
示例6: connect
public function connect()
{
$connectionString = $this->config['dbtype'] . ':host=' . $this->config['dbhost'] . ';dbname=' . $this->config['dbname'];
$db = new PDO($connectionString, $this->config['dbuser'], $this->config['dbpass']);
if ($db === FALSE) {
xhprof_error("Could not connect to db");
$run_desc = "could not connect to db";
throw new Exception("Unable to connect to database");
return FALSE;
}
$this->db = $db;
$this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
}
示例7: db
protected function db()
{
global $_xhprof;
$connectionInfo = array("UID" => $_xhprof['dbuser'], "PWD" => $_xhprof['dbpass'], "Database" => $_xhprof['dbname'], "ReturnDatesAsStrings" => TRUE);
$linkid = sqlsrv_connect($_xhprof['dbhost'], $connectionInfo);
if ($linkid === FALSE) {
xhprof_error("Could not connect to db");
$run_desc = "could not connect to db";
throw new Exception("Unable to connect to database");
return false;
}
$this->linkID = $linkid;
}
示例8: save_run
public function save_run($xhprof_data, $type, $run_id = null)
{
// Use PHP serialize function to store the XHProf's
// raw profiler data.
$xhprof_data = serialize($xhprof_data);
if ($run_id === null) {
$run_id = $this->gen_run_id($type);
}
$file_name = $this->file_name($run_id, $type);
$file = fopen($file_name, 'w');
if ($file) {
fwrite($file, $xhprof_data);
fclose($file);
} else {
xhprof_error("Could not open {$file_name}\n");
}
if (defined("ECAE_MODE") && constant("ECAE_MODE")) {
// 如果是存放在ecae中返回的是ECAE S3存放id
return ecae_file_save(constant("ECAE_SITE_NAME") . "-private", $file_name, array("path" => "xphrof", "name" => $run_id . ".txt"));
}
// echo "Saved run in {$file_name}.\nRun id = {$run_id}.\n";
return $run_id;
}
示例9: xhprof_param_init
xhprof_param_init($params);
if (!empty($run)) {
// single run mode
$raw_data = $xhprof_runs_impl->get_run($run, $source, $desc_unused);
$functions = xhprof_get_matching_functions($q, $raw_data);
} else {
if (!empty($run1) && !empty($run2)) {
// diff mode
$raw_data = $xhprof_runs_impl->get_run($run1, $source, $desc_unused);
$functions1 = xhprof_get_matching_functions($q, $raw_data);
$raw_data = $xhprof_runs_impl->get_run($run2, $source, $desc_unused);
$functions2 = xhprof_get_matching_functions($q, $raw_data);
$functions = array_unique(array_merge($functions1, $functions2));
asort($functions);
} else {
xhprof_error("no valid runs specified to typeahead endpoint");
$functions = array();
}
}
// If exact match is present move it to the front
if (in_array($q, $functions)) {
$old_functions = $functions;
$functions = array($q);
foreach ($old_functions as $f) {
// exact match case has already been added to the front
if ($f != $q) {
$functions[] = $f;
}
}
}
foreach ($functions as $f) {
示例10: __construct
public function __construct($dir = null)
{
// if user hasn't passed a directory location,
// we use the xhprof.output_dir ini setting
// if specified, else we default to the directory
// in which the error_log file resides.
if (empty($dir)) {
$dir = ini_get("xhprof.output_dir");
if (empty($dir)) {
// some default that at least works on unix...
$dir = "/tmp";
xhprof_error("Warning: Must specify directory location for XHProf runs. " . "Trying {$dir} as default. You can either pass the " . "directory location as an argument to the constructor " . "for XHProfRuns_Default() or set xhprof.output_dir " . "ini param.");
}
}
$this->dir = $dir;
}
示例11: normalize_metrics
/**
* Takes raw XHProf data that was aggregated over "$num_runs" number
* of runs averages/nomalizes the data. Essentially the various metrics
* collected are divided by $num_runs.
*/
protected function normalize_metrics($raw_data, $num_runs)
{
if (empty($raw_data) || $num_runs == 0) {
return $raw_data;
}
$raw_data_total = array();
if (isset($raw_data["==>main()"]) && isset($raw_data["main()"])) {
xhprof_error("XHProf Error: both ==>main() and main() set in raw data...");
}
foreach ($raw_data as $parent_child => $info) {
foreach ($info as $metric => $value) {
$raw_data_total[$parent_child][$metric] = $value / $num_runs;
}
}
return $raw_data_total;
}
示例12: xhprof_param_init
/**
* Initialize params from URL query string. The function
* creates globals variables for each of the params
* and if the URL query string doesn't specify a particular
* param initializes them with the corresponding default
* value specified in the input.
*
* @params array $params An array whose keys are the names
* of URL params who value needs to
* be retrieved from the URL query
* string. PHP globals are created
* with these names. The value is
* itself an array with 2-elems (the
* param type, and its default value).
* If a param is not specified in the
* query string the default value is
* used.
* @author Kannan
*/
function xhprof_param_init($params)
{
/* Create variables specified in $params keys, init defaults */
foreach ($params as $k => $v) {
switch ($v[0]) {
case XHPROF_STRING_PARAM:
$p = xhprof_get_string_param($k, $v[1]);
break;
case XHPROF_UINT_PARAM:
$p = xhprof_get_uint_param($k, $v[1]);
break;
case XHPROF_FLOAT_PARAM:
$p = xhprof_get_float_param($k, $v[1]);
break;
case XHPROF_BOOL_PARAM:
$p = xhprof_get_bool_param($k, $v[1]);
break;
default:
xhprof_error("Invalid param type passed to xhprof_param_init: " . $v[0]);
// gg: let the script go on anyway
//exit();
throw new Exception("Invalid param type passed to xhprof_param_init: " . $v[0]);
}
// create a global variable using the parameter name.
$GLOBALS[$k] = $p;
}
}
示例13: xhprof_param_init
/**
* Initialize params from URL query string. The function
* creates globals variables for each of the params
* and if the URL query string doesn't specify a particular
* param initializes them with the corresponding default
* value specified in the input.
*
* @params array $params An array whose keys are the names
* of URL params who value needs to
* be retrieved from the URL query
* string. PHP globals are created
* with these names. The value is
* itself an array with 2-elems (the
* param type, and its default value).
* If a param is not specified in the
* query string the default value is
* used.
* @author Kannan
*/
function xhprof_param_init($params)
{
/* Create variables specified in $params keys, init defaults */
foreach ($params as $k => $v) {
switch ($v[0]) {
case XHPROF_STRING_PARAM:
$p = xhprof_get_string_param($k, $v[1]);
break;
case XHPROF_UINT_PARAM:
$p = xhprof_get_uint_param($k, $v[1]);
break;
case XHPROF_FLOAT_PARAM:
$p = xhprof_get_float_param($k, $v[1]);
break;
case XHPROF_BOOL_PARAM:
$p = xhprof_get_bool_param($k, $v[1]);
break;
default:
xhprof_error("Invalid param type passed to xhprof_param_init: " . $v[0]);
exit;
}
if ($k === 'run') {
$p = implode(',', array_filter(explode(',', $p), 'ctype_xdigit'));
}
// create a global variable using the parameter name.
$GLOBALS[$k] = $p;
}
}
示例14: save_run
/**
* Given some run data, one type and, optionally, one runid
* store the information in DB
*
* Note that $type is completely ignored
*/
public function save_run($xhprof_data, $type, $run_id = null)
{
global $DB, $CFG;
if (is_null($this->url)) {
xhprof_error("Warning: You must use the prepare_run() method before saving it");
}
// Calculate runid if needed
$this->runid = is_null($run_id) ? md5($this->url . '-' . uniqid()) : $run_id;
// Calculate totals
$this->totalexecutiontime = $xhprof_data['main()']['wt'];
$this->totalcputime = $xhprof_data['main()']['cpu'];
$this->totalcalls = array_reduce($xhprof_data, array($this, 'sum_calls'));
$this->totalmemory = $xhprof_data['main()']['mu'];
// Prepare data
$rec = new stdClass();
$rec->runid = $this->runid;
$rec->url = $this->url;
$rec->data = base64_encode(gzcompress(serialize($xhprof_data), 9));
$rec->totalexecutiontime = $this->totalexecutiontime;
$rec->totalcputime = $this->totalcputime;
$rec->totalcalls = $this->totalcalls;
$rec->totalmemory = $this->totalmemory;
$rec->timecreated = $this->timecreated;
$DB->insert_record('profiling', $rec);
if (PHPUNIT_TEST) {
// Calculate export variables.
$tempdir = 'profiling';
make_temp_directory($tempdir);
$runids = array($this->runid);
$filename = $this->runid . '.mpr';
$filepath = $CFG->tempdir . '/' . $tempdir . '/' . $filename;
// Generate the mpr file and send it.
if (profiling_export_runs($runids, $filepath)) {
fprintf(STDERR, "Profiling data saved to: " . $filepath . "\n");
}
}
return $this->runid;
}
示例15: save_run_fqpn
public function save_run_fqpn($xhprof_data, $type, $run_id = null, $run_path)
{
// Use PHP serialize function to store the XHProf's
// raw profiler data.
if (function_exists(igbinary_serialize)) {
$xhprof_data = igbinary_serialize($xhprof_data);
} else {
$xhprof_data = serialize($xhprof_data);
}
if ($run_id === null) {
$run_id = $this->gen_run_id($type);
}
$file_name = "{$run_path}/{$run_id}.{$type}";
$file = fopen($file_name, 'w');
if ($file) {
fwrite($file, $xhprof_data);
fclose($file);
} else {
xhprof_error("Could not open {$file_name}\n");
}
// echo "Saved run in {$file_name}.\nRun id = {$run_id}.\n";
return $run_id;
}