本文整理汇总了PHP中xhprof_error函数的典型用法代码示例。如果您正苦于以下问题:PHP xhprof_error函数的具体用法?PHP xhprof_error怎么用?PHP xhprof_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xhprof_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:Seritech,项目名称:xhprof,代码行数:10,代码来源:Mysqli.php
示例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;
}
开发者ID:ChrisWesterfield,项目名称:MJR.ONE-CP,代码行数:11,代码来源:Mssql.php
示例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);
}
开发者ID:illusionuk,项目名称:Drupal-XHProf,代码行数:21,代码来源:callgraph_utils.php
示例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;
}
开发者ID:ChrisWesterfield,项目名称:MJR.ONE-CP,代码行数:11,代码来源:Sqlsrv.php
示例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;
}
开发者ID:rmarscher,项目名称:xhprof,代码行数:13,代码来源:xhprof_runs_mysqli.php
示例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);
}
开发者ID:42mate,项目名称:xhprof,代码行数:13,代码来源:Pdo.php
示例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;
}
开发者ID:helgi,项目名称:xhprof,代码行数:13,代码来源:xhprof_runs_sqlsrv.php
示例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;
}
开发者ID:sss201413,项目名称:ecstore,代码行数:23,代码来源:xhprof_runs.php
示例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) {
开发者ID:philip,项目名称:xhprof,代码行数:31,代码来源:typeahead_common.php
示例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;
}
开发者ID:illusionuk,项目名称:Drupal-XHProf,代码行数:16,代码来源:xhprof_runs.php
示例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;
}
开发者ID:sandstorm,项目名称:plumber,代码行数:21,代码来源:xhprof_ui.php
示例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;
}
}
开发者ID:gggeek,项目名称:ezperformancelogger,代码行数:46,代码来源:xhprof_lib.php
示例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;
}
}
开发者ID:nosun,项目名称:xhprof,代码行数:47,代码来源:xhprof_lib.php
示例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;
}
开发者ID:dg711,项目名称:moodle,代码行数:44,代码来源:xhprof_moodle.php
示例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;
}
开发者ID:shourya07,项目名称:zperfmon,代码行数:23,代码来源:xhprof_runs.php
示例16: xhprof_get_content_by_run
/**
* Generate image content from phprof run id.
*
* @param \Sugarcrm\XHProf\Viewer\Storage\StorageInterface $storage An object that implements
* the iXHProfRuns interface
* @param run_id, integer, the unique id for the phprof run, this is the
* primary key for phprof database table.
* @param type, string, one of the supported image types. See also
* $xhprof_legal_image_types.
* @param threshold, float, the threshold value [0,1). The functions in the
* raw_data whose exclusive wall times ratio are below the
* threshold will be filtered out and won't apprear in the
* generated image.
* @param func, string, the focus function.
* @returns, string, the DOT script to generate image.
*
* @author cjiang
*/
function xhprof_get_content_by_run(\Sugarcrm\XHProf\Viewer\Storage\StorageInterface $storage, $run_id, $type, $threshold, $func, $source, $critical_path)
{
if (!$run_id) {
return "";
}
$raw_data = $storage->getRunXHProfData($run_id);
if (!$raw_data) {
xhprof_error("Raw data is empty");
return "";
}
$script = xhprof_generate_dot_script($raw_data, $threshold, $source, $run_id, $func, $critical_path);
$content = xhprof_generate_image_by_dot($script, $type);
return $content;
}
开发者ID:sugarcrm,项目名称:xhprof-viewer,代码行数:32,代码来源:callgraph_utils.php
示例17: xhprof_prune_run
function xhprof_prune_run($raw_data, $prune_percent)
{
$main_info = $raw_data["main()"];
if (empty($main_info)) {
xhprof_error("XHProf: main() missing in raw data");
return false;
}
// raw data should contain either wall time or samples information...
if (isset($main_info["wt"])) {
$prune_metric = "wt";
} else {
if (isset($main_info["samples"])) {
$prune_metric = "samples";
} else {
xhprof_error("XHProf: for main() we must have either wt " . "or samples attribute set");
return false;
}
}
// determine the metrics present in the raw data..
$metrics = array();
foreach ($main_info as $metric => $val) {
if (isset($val)) {
$metrics[] = $metric;
}
}
$prune_threshold = $main_info[$prune_metric] * $prune_percent / 100.0;
init_metrics($raw_data, null, null, false);
$flat_info = xhprof_compute_inclusive_times($raw_data);
foreach ($raw_data as $parent_child => $info) {
list($parent, $child) = xhprof_parse_parent_child($parent_child);
// is this child's overall total from all parents less than threshold?
if ($flat_info[$child][$prune_metric] < $prune_threshold) {
unset($raw_data[$parent_child]);
// prune the edge
} else {
if ($parent && $parent != "__pruned__()" && $flat_info[$parent][$prune_metric] < $prune_threshold) {
// Parent's overall inclusive metric is less than a threshold.
// All edges to the parent node will get nuked, and this child will
// be a dangling child.
// So instead change its parent to be a special function __pruned__().
$pruned_edge = xhprof_build_parent_child_key("__pruned__()", $child);
if (isset($raw_data[$pruned_edge])) {
foreach ($metrics as $metric) {
$raw_data[$pruned_edge][$metric] += $raw_data[$parent_child][$metric];
}
} else {
$raw_data[$pruned_edge] = $raw_data[$parent_child];
}
unset($raw_data[$parent_child]);
// prune the edge
}
}
}
return $raw_data;
}
开发者ID:sandstorm,项目名称:plumber,代码行数:55,代码来源:compute.php
示例18: 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");
}
// echo "Saved run in {$file_name}.\nRun id = {$run_id}.\n";
return $run_id;
}
开发者ID:LMSeXT,项目名称:SAWEE-WS_server-lib,代码行数:19,代码来源:xhprof_runs.php
示例19: 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;
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(serialize($xhprof_data));
$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);
return $this->runid;
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:32,代码来源:xhprof_moodle.php
示例20: xhprof_get_content_by_run
/**
* Generate image content from phprof run id.
*
* @param object $xhprof_runs_impl An object that implements
* the iXHProfRuns interface
* @param run_id, integer, the unique id for the phprof run, this is the
* primary key for phprof database table.
* @param type, string, one of the supported image types. See also
* $xhprof_legal_image_types.
* @param threshold, float, the threshold value [0,1). The functions in the
* raw_data whose exclusive wall times ratio are below the
* threshold will be filtered out and won't apprear in the
* generated image.
* @param func, string, the focus function.
* @returns, string, the DOT script to generate image.
*
* @author cjiang
*/
function xhprof_get_content_by_run($xhprof_runs_impl, $run_id, $type, $threshold, $func, $source, $critical_path)
{
if (!$run_id) {
return "";
}
$raw_data = $xhprof_runs_impl->get_run($run_id, $source, $description);
if (!$raw_data) {
xhprof_error("Raw data is empty");
return "";
}
$script = xhprof_generate_dot_script($raw_data, $threshold, $source, $description, $func, $critical_path);
$content = xhprof_generate_image_by_dot($script, $type);
return $content;
}
开发者ID:hexcode007,项目名称:yfcms,代码行数:32,代码来源:callgraph_utils.php
注:本文中的xhprof_error函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论