/** * @param Symbol[] $symbols * * @return array */ protected function computeFlatInfo($symbols) { $metrics = $this->getMetrics(); // Compute inclusive times for each function. $symbol_tab = $this->computeInclusiveTimes($symbols); // Total metric value is the metric value for "main()". foreach ($metrics as $metric) { $this->overall_totals[$metric] = $this->mainSymbol->getMetric($metric); } // Initialize exclusive (self) metric value to inclusive metric value to start with. // In the same pass, also add up the total number of function calls. foreach ($symbol_tab as $symbol => $info) { foreach ($metrics as $metric) { $symbol_tab[$symbol]["excl_" . $metric] = $symbol_tab[$symbol][$metric]; } // Keep track of total number of calls. $this->overall_totals["ct"] += $info["ct"]; } // Adjust exclusive times by deducting inclusive time of children. foreach ($symbols as $symbol) { $parent = $symbol->getParent(); if ($parent) { foreach ($metrics as $metric) { // make sure the parent exists hasn't been pruned. if (isset($symbol_tab[$parent])) { $symbol_tab[$parent]["excl_" . $metric] -= $symbol->getMetric($metric); } } } } return $symbol_tab; }
/** * @param $data * * @return array */ private function parseSymbols($data) { $symbols = array(); foreach ($data as $parent_child => $metrics) { if (!isset($metrics['cpu'])) { $metrics['cpu'] = NULL; } if (!isset($metrics['mu'])) { $metrics['mu'] = NULL; } if (!isset($metrics['pmu'])) { $metrics['pmu'] = NULL; } $symbol = new Symbol($parent_child, $metrics['ct'], $metrics['wt'], $metrics['cpu'], $metrics['mu'], $metrics['pmu']); $symbols[$parent_child] = $symbol; if ($symbol->getParent() == NULL) { $this->mainSymbol = $symbol; } } return $symbols; }