4 * This file is part of Twig.
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
13 * @author Fabien Potencier <fabien@symfony.com>
17 class Twig_Profiler_Dumper_Blackfire
19 public function dump(Twig_Profiler_Profile
$profile)
22 $this->dumpProfile('main()', $profile, $data);
23 $this->dumpChildren('main()', $profile, $data);
25 $start = sprintf('%f', microtime(true));
27 file-format: BlackfireProbe
28 cost-dimensions: wt mu pmu
29 request-start: {$start}
34 foreach ($data as $name => $values) {
35 $str .= "{$name}//{$values['ct']} {$values['wt']} {$values['mu']} {$values['pmu']}\n";
41 private function dumpChildren($parent, Twig_Profiler_Profile
$profile, &$data)
43 foreach ($profile as $p) {
44 if ($p->isTemplate()) {
45 $name = $p->getTemplate();
47 $name = sprintf('%s::%s(%s)', $p->getTemplate(), $p->getType(), $p->getName());
49 $this->dumpProfile(sprintf('%s==>%s', $parent, $name), $p, $data);
50 $this->dumpChildren($name, $p, $data);
54 private function dumpProfile($edge, Twig_Profiler_Profile
$profile, &$data)
56 if (isset($data[$edge])) {
57 $data[$edge]['ct'] +
= 1;
58 $data[$edge]['wt'] +
= floor($profile->getDuration() * 1000000);
59 $data[$edge]['mu'] +
= $profile->getMemoryUsage();
60 $data[$edge]['pmu'] +
= $profile->getPeakMemoryUsage();
64 'wt' => floor($profile->getDuration() * 1000000),
65 'mu' => $profile->getMemoryUsage(),
66 'pmu' => $profile->getPeakMemoryUsage(),
72 class_alias('Twig_Profiler_Dumper_Blackfire', 'Twig\Profiler\Dumper\BlackfireDumper', false);