PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/extension/tests/common.php

http://github.com/preinheimer/xhprof
PHP | 35 lines | 17 code | 4 blank | 14 comment | 3 complexity | 8c5b803292bdfa6b179f4811e7cd815c MD5 | raw file
 1<?php
 2
 3/**
 4 * Print xhprof raw data (essentially a callgraph) in a canonical style,
 5 * so that even if the ordering of things within the raw_data (which is
 6 * an associative array) changes in future implementations the output
 7 * remains stable.
 8 *
 9 * Also, suppress output of variable quantities (such as time, memory)
10 * so that reference output of tests doesn't need any additional masking.
11 *
12 * @author Kannan
13 */
14function print_canonical($xhprof_data) {
15  ksort($xhprof_data);
16  foreach($xhprof_data as $func => $metrics) {
17    echo str_pad($func, 40) . ":";
18    ksort($metrics);
19    foreach ($metrics as $name => $value) {
20
21      // Only call counts are stable.
22      // Wild card everything else. We still print
23      // the metric name to ensure it was collected.
24      if ($name != "ct") {
25        $value = "*";
26      } else {
27        $value = str_pad($value, 8, " ", STR_PAD_LEFT);
28      }
29
30      echo " {$name}={$value};";
31    }
32    echo "\n";
33  }
34}
35