Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Use JSON instead of PHP serialization, allows for storage of large …
…profiles

- Show pie-chart colors in function listing
  • Loading branch information
Davey Shafik committed Apr 20, 2011
1 parent 8628d8c commit 3ad8eed
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 492 deletions.
5 changes: 0 additions & 5 deletions xhprof_html/callgraph.php
Expand Up @@ -30,11 +30,6 @@
*/
require ("../xhprof_lib/config.php");

if (!in_array($_SERVER['REMOTE_ADDR'], $controlIPs))
{
die();
}

// by default assume that xhprof_html & xhprof_lib directories
// are at the same level.
if (!defined('XHPROF_LIB_ROOT')) {
Expand Down
6 changes: 0 additions & 6 deletions xhprof_html/index.php
Expand Up @@ -6,12 +6,6 @@
include_once XHPROF_LIB_ROOT . '/display/xhprof.php';
include (XHPROF_LIB_ROOT . "/utils/common.php");

if (!in_array($_SERVER['REMOTE_ADDR'], $controlIPs))
{
die("You do not have permission to view this page.");
}


// param name, its type, and default value
$params = array('run' => array(XHPROF_STRING_PARAM, ''),
'wts' => array(XHPROF_STRING_PARAM, ''),
Expand Down
15 changes: 14 additions & 1 deletion xhprof_lib/display/xhprof.php
Expand Up @@ -808,6 +808,20 @@ function print_flat_data($url_params, $title, $flat_data, $sort, $run1, $run2, $
$data_copy = _aggregateCalls($data_copy);
usort($data_copy, 'sortWT');

$iterations = 0;
$colors = array('#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92', '#EAFEBB', '#FEB4B1', '#2B6979', '#E9D6FE', '#FECDA3', '#FED980');
foreach($data_copy as $datapoint)
{
if (++$iterations > 14)
{
$function_color[$datapoint['fn']] = $colors[14];
}else
{
$function_color[$datapoint['fn']] = $colors[$iterations-1];
}
}

_getAggregatedCalls($flat_data);
include( "../xhprof_lib/templates/profChart.phtml");
include( "../xhprof_lib/templates/profTable.phtml");

Expand Down Expand Up @@ -1361,7 +1375,6 @@ function displayXHProfReport($xhprof_runs_impl, $url_params, $source,
list($xhprof_data, $run_details) = $xhprof_runs_impl->get_run($runs_array[0],
$source,
$description);

} else {
if (!empty($wts)) {
$wts_array = explode(",", $wts);
Expand Down
24 changes: 12 additions & 12 deletions xhprof_lib/templates/diff_run_header_block.phtml
Expand Up @@ -26,12 +26,12 @@ print('<div id="view-diff-tables">');

print('<div class="colone">');
// cookie diff data from array position 0
$cookieArr0 = unserialize($xhprof_runs_impl->run_details[0]['cookie']);
$cookieArr1 = unserialize($xhprof_runs_impl->run_details[1]['cookie']);
$getArr0 = unserialize($xhprof_runs_impl->run_details[0]['get']);
$getArr1 = unserialize($xhprof_runs_impl->run_details[1]['get']);
$postArr0 = unserialize($xhprof_runs_impl->run_details[0]['post']);
$postArr1 = unserialize($xhprof_runs_impl->run_details[1]['post']);
$cookieArr0 = json_decode($xhprof_runs_impl->run_details[0]['cookie'], true);
$cookieArr1 = json_decode($xhprof_runs_impl->run_details[1]['cookie'], true);
$getArr0 = json_decode($xhprof_runs_impl->run_details[0]['get'], true);
$getArr1 = json_decode($xhprof_runs_impl->run_details[1]['get'], true);
$postArr0 = json_decode($xhprof_runs_impl->run_details[0]['post'], true);
$postArr1 = json_decode($xhprof_runs_impl->run_details[1]['post'], true);


print ('<div class="box-fix-small">');
Expand All @@ -58,7 +58,7 @@ print('<div id="view-diff-tables">');

// get diff data from array position 0

// $getArr0 = unserialize($xhprof_runs_impl->run_details[0]['get']);
// $getArr0 = json_decode($xhprof_runs_impl->run_details[0]['get']);
print '<div class="box-fix-small-cl">';
print '<table class="box-tables-small">';
print "<thead>";
Expand Down Expand Up @@ -86,7 +86,7 @@ print('<div id="view-diff-tables">');
print "</div>";

// post diff data from array position 0
// $postArr0 = unserialize($xhprof_runs_impl->run_details[0]['post']);
// $postArr0 = json_decode($xhprof_runs_impl->run_details[0]['post']);
print '<div class="box-fix-small-cl">';
print '<table class="box-tables-small">';
print "<thead>";
Expand Down Expand Up @@ -159,7 +159,7 @@ print('<div id="view-diff-tables">');
print "</head>";
print "<tbody>";
// cookie diff data from array position 1
//$cookieArr1 = unserialize($xhprof_runs_impl->run_details[1]['cookie']);
//$cookieArr1 = json_decode($xhprof_runs_impl->run_details[1]['cookie']);

foreach($cookieArr1 as $key=>$value){
echo "<tr>";
Expand All @@ -184,7 +184,7 @@ print('<div id="view-diff-tables">');
print "</head>";
print "<tbody>";
// get diff data from array position 1
// $getArr1 = unserialize($xhprof_runs_impl->run_details[1]['get']);
// $getArr1 = json_decode($xhprof_runs_impl->run_details[1]['get']);

foreach($getArr1 as $key=>$value){
echo "<tr>";
Expand Down Expand Up @@ -213,7 +213,7 @@ print('<div id="view-diff-tables">');
print "</head>";
print "<tbody>";
// post diff data from array position 1
// $postArr1 = unserialize($xhprof_runs_impl->run_details[1]['post']);
// $postArr1 = json_decode($xhprof_runs_impl->run_details[1]['post']);

foreach($postArr1 as $key=>$value){
echo "<tr>";
Expand All @@ -231,4 +231,4 @@ print('<div id="view-diff-tables">');
</table>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions xhprof_lib/templates/profChart.phtml
@@ -1,4 +1,5 @@
<script type="text/javascript">
Highcharts.setOptions({colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92', '#EAFEBB', '#FEB4B1', '#2B6979', '#E9D6FE', '#FECDA3', '#FED980']});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
Expand Down
12 changes: 10 additions & 2 deletions xhprof_lib/templates/profTable.phtml
@@ -1,6 +1,7 @@
<table id="box-table-a" class="tablesorter" summary="Stats">
<thead>
<tr>
<th>Group</th>
<th>Function</th>
<th>Call Count</th>
<th>Wall Time</th>
Expand All @@ -16,9 +17,16 @@
<tbody>
<?php
foreach($flat_data as $element)
{?>
{
if (isset($element['group'])) {
$color = $function_color[$element['group']];
} else {
$color = $function_color[$element['fn']];
}
?>

<tr>
<td style="background-color: <?php echo $color; ?>;"><span style="display: none"><?php echo $color; ?></span>&nbsp;</td>
<td><a href="?run=<?php echo $run1; ?>&amp;symbol=<?php echo urlencode($element['fn']); ?>"><?php echo htmlentities($element['fn'], ENT_QUOTES, 'UTF-8'); ?></a></td>
<td><?php echo $element['ct']; ?></td>
<td><?php echo $element['wt']; ?></td>
Expand All @@ -41,4 +49,4 @@ $(document).ready(function()
$("#box-table-a").tablesorter( {sortList: []} );
}
);
</script>
</script>
6 changes: 3 additions & 3 deletions xhprof_lib/templates/single_run_header_block.phtml
Expand Up @@ -64,7 +64,7 @@
</thead>
<tbody>
<?php
$cookieArr = unserialize($xhprof_runs_impl->run_details['cookie']);
$cookieArr = json_decode($xhprof_runs_impl->run_details['cookie'], true);
// echo '<pre>'.print_r($cookieArr, true).'</pre>';
foreach($cookieArr as $key=>$value){
if (is_array($value))
Expand All @@ -90,7 +90,7 @@
</thead>
<tbody>
<?php
$getArr = unserialize($xhprof_runs_impl->run_details['get']);
$getArr = json_decode($xhprof_runs_impl->run_details['get'], true);
// echo '<pre>'.print_r($getArr, true).'</pre>';
foreach($getArr as $key=>$value)
{
Expand All @@ -117,7 +117,7 @@
</thead>
<tbody>
<?php
$postArr = unserialize($xhprof_runs_impl->run_details['post']);
$postArr = json_decode($xhprof_runs_impl->run_details['post'], true);
// echo '<pre>'.print_r($postArr, true).'</pre>';
foreach($postArr as $key=>$value){
if (is_array($value))
Expand Down

0 comments on commit 3ad8eed

Please sign in to comment.