Example #1
0
<?php

function print_num()
{
    $num = 42;
    for ($i = 1; $i <= 32; $i++) {
        echo $num . ' ';
        $num--;
    }
}
?>

<h3><?php 
print_num();
?>
</h3>
<div><?php 
print_num();
?>
</div>
<p><?php 
print_num();
?>
</p>
Example #2
0
$xhprof_runs_impl = new XHProfRuns_Default();
$run1_data = $xhprof_runs_impl->get_run($run1, $source, $description1);
$run2_data = $xhprof_runs_impl->get_run($run2, $source, $description2);
$run_delta = xhprof_compute_diff($run1_data, $run2_data);
$symbol_tab = xhprof_compute_flat_info($run_delta, $totals);
$symbol_tab1 = xhprof_compute_flat_info($run1_data, $totals_1);
$symbol_tab2 = xhprof_compute_flat_info($run2_data, $totals_2);
$metrics = xhprof_get_metrics($run_delta);
function print_pct($numer, $denom)
{
    if ($denom == 0) {
        $pct = "N/A%";
    } else {
        $pct = xhprof_percent_format($numer / abs($denom));
    }
    return $pct;
}
function print_num($num, $fmt_func = null)
{
    if (!empty($fmt_func)) {
        $num = call_user_func($fmt_func, $num);
    }
    return $num;
}
print "=== {$extra} compared ({$run1}..{$run2}):\n\n";
array_unshift($metrics, 'ct');
foreach ($metrics as $metric) {
    $m = $metric;
    $fmt = $format_cbk[$m];
    print str_pad($m, 4) . ': ' . print_num($totals_1[$m], $fmt) . '|' . print_num($totals_2[$m], $fmt) . '|' . print_num($totals_2[$m] - $totals_1[$m], $fmt) . '|' . print_pct($totals_2[$m] - $totals_1[$m], $totals_1[$m]) . "\n";
}