Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2595586
D25836.1730395288.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
5 KB
Referenced Files
None
Subscribers
None
D25836.1730395288.diff
View Options
diff --git a/externals/xhprof/xhprof_lib.php b/externals/xhprof/xhprof_lib.php
--- a/externals/xhprof/xhprof_lib.php
+++ b/externals/xhprof/xhprof_lib.php
@@ -19,8 +19,10 @@
// Do not add any display specific code here.
//
-function xhprof_error($message) {
- error_log($message);
+if (!function_exists('xhprof_error')) {
+ function xhprof_error($message) {
+ error_log($message);
+ }
}
/*
@@ -31,8 +33,8 @@
*/
function xhprof_get_possible_metrics() {
static $possible_metrics =
- array("wt" => array("Wall", "microsecs", "walltime" ),
- "ut" => array("User", "microsecs", "user cpu time" ),
+ array("wt" => array("Wall", "microsecs", "walltime"),
+ "ut" => array("User", "microsecs", "user cpu time"),
"st" => array("Sys", "microsecs", "system cpu time"),
"cpu" => array("Cpu", "microsecs", "cpu time"),
"mu" => array("MUse", "bytes", "memory usage"),
@@ -41,6 +43,82 @@
return $possible_metrics;
}
+/**
+ * Initialize the metrics we'll display based on the information
+ * in the raw data.
+ *
+ * @author Kannan
+ */
+function init_metrics($xhprof_data, $rep_symbol, $sort, $diff_report = false) {
+ global $stats;
+ global $pc_stats;
+ global $metrics;
+ global $diff_mode;
+ global $sortable_columns;
+ global $sort_col;
+ global $display_calls;
+
+ $diff_mode = $diff_report;
+
+ if (!empty($sort)) {
+ if (array_key_exists($sort, $sortable_columns)) {
+ $sort_col = $sort;
+ } else {
+ print("Invalid Sort Key $sort specified in URL");
+ }
+ }
+
+ // For C++ profiler runs, walltime attribute isn't present.
+ // In that case, use "samples" as the default sort column.
+ if (!isset($xhprof_data["main()"]["wt"])) {
+
+ if ($sort_col == "wt") {
+ $sort_col = "samples";
+ }
+
+ // C++ profiler data doesn't have call counts.
+ // ideally we should check to see if "ct" metric
+ // is present for "main()". But currently "ct"
+ // metric is artificially set to 1. So, relying
+ // on absence of "wt" metric instead.
+ $display_calls = false;
+ } else {
+ $display_calls = true;
+ }
+
+ // parent/child report doesn't support exclusive times yet.
+ // So, change sort hyperlinks to closest fit.
+ if (!empty($rep_symbol)) {
+ $sort_col = str_replace("excl_", "", $sort_col);
+ }
+
+ if ($display_calls) {
+ $stats = array("fn", "ct", "Calls%");
+ } else {
+ $stats = array("fn");
+ }
+
+ $pc_stats = $stats;
+
+ $possible_metrics = xhprof_get_possible_metrics();
+ foreach ($possible_metrics as $metric => $desc) {
+ if (isset($xhprof_data["main()"][$metric])) {
+ $metrics[] = $metric;
+ // flat (top-level reports): we can compute
+ // exclusive metrics reports as well.
+ $stats[] = $metric;
+ $stats[] = "I" . $desc[0] . "%";
+ $stats[] = "excl_" . $metric;
+ $stats[] = "E" . $desc[0] . "%";
+
+ // parent/child report for a function: we can
+ // only breakdown inclusive times correctly.
+ $pc_stats[] = $metric;
+ $pc_stats[] = "I" . $desc[0] . "%";
+ }
+ }
+}
+
/*
* Get the list of metrics present in $xhprof_data as an array.
*
@@ -259,9 +337,9 @@
}
$bad_runs = array();
- foreach($runs as $idx => $run_id) {
+ foreach ($runs as $idx => $run_id) {
- $raw_data = $xhprof_runs_impl->get_run($run_id, $source, '?');
+ $raw_data = $xhprof_runs_impl->get_run($run_id, $source, $description);
// use the first run to derive what metrics to aggregate on.
if ($idx == 0) {
@@ -283,7 +361,7 @@
}
if ($use_script_name) {
- $page = '?';
+ $page = $description;
// create a fake function '__script::$page', and have and edge from
// main() to '__script::$page'. We will also need edges to transfer
@@ -294,7 +372,7 @@
// it shows up above the new entry in reports sorted by
// inclusive metrics or call counts.
if ($page) {
- foreach($raw_data["main()"] as $metric => $val) {
+ foreach ($raw_data["main()"] as $metric => $val) {
$fake_edge[$metric] = $val;
$new_main[$metric] = $val + 0.00001;
}
@@ -316,7 +394,7 @@
// if this is an old edge originating from main(), it now
// needs to be from '__script::$page'
if (substr($parent_child, 0, 9) == "main()==>") {
- $child =substr($parent_child, 9);
+ $child = substr($parent_child, 9);
// ignore the newly added edge from main()
if (substr($child, 0, 10) != "__script::") {
$parent_child = xhprof_build_parent_child_key("__script::$page",
@@ -381,7 +459,7 @@
$metrics = xhprof_get_metrics($raw_data);
- $overall_totals = array( "ct" => 0,
+ $overall_totals = array("ct" => 0,
"wt" => 0,
"ut" => 0,
"st" => 0,
@@ -829,6 +907,14 @@
exit();
}
+ if ($k === 'run') {
+ $p = implode(',', array_filter(explode(',', $p), 'ctype_xdigit'));
+ }
+
+ if ($k == 'symbol') {
+ $p = strip_tags($p);
+ }
+
// create a global variable using the parameter name.
$GLOBALS[$k] = $p;
}
@@ -863,4 +949,3 @@
return ($res);
}
-
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 31, 17:21 (22 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
954145
Default Alt Text
D25836.1730395288.diff (5 KB)
Attached To
Mode
D25836: Update xhprof to latest upstream version 2.3.10
Attached
Detach File
Event Timeline
Log In to Comment