ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Blackfire.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
18{
19 public function dump(Twig_Profiler_Profile $profile)
20 {
21 $data = array();
22 $this->dumpProfile('main()', $profile, $data);
23 $this->dumpChildren('main()', $profile, $data);
24
25 $start = sprintf('%f', microtime(true));
26 $str = <<<EOF
27file-format: BlackfireProbe
28cost-dimensions: wt mu pmu
29request-start: {$start}
30
31
32EOF;
33
34 foreach ($data as $name => $values) {
35 $str .= "{$name}//{$values['ct']} {$values['wt']} {$values['mu']} {$values['pmu']}\n";
36 }
37
38 return $str;
39 }
40
41 private function dumpChildren($parent, Twig_Profiler_Profile $profile, &$data)
42 {
43 foreach ($profile as $p) {
44 if ($p->isTemplate()) {
45 $name = $p->getTemplate();
46 } else {
47 $name = sprintf('%s::%s(%s)', $p->getTemplate(), $p->getType(), $p->getName());
48 }
49 $this->dumpProfile(sprintf('%s==>%s', $parent, $name), $p, $data);
50 $this->dumpChildren($name, $p, $data);
51 }
52 }
53
54 private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
55 {
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();
61 } else {
62 $data[$edge] = array(
63 'ct' => 1,
64 'wt' => floor($profile->getDuration() * 1000000),
65 'mu' => $profile->getMemoryUsage(),
66 'pmu' => $profile->getPeakMemoryUsage(),
67 );
68 }
69 }
70}
71
72class_alias('Twig_Profiler_Dumper_Blackfire', 'Twig\Profiler\Dumper\BlackfireDumper', false);
sprintf('%.4f', $callTime)
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
An exception for terminatinating execution or to throw for unit testing.
dump(Twig_Profiler_Profile $profile)
Definition: Blackfire.php:19
dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
Definition: Blackfire.php:54
dumpChildren($parent, Twig_Profiler_Profile $profile, &$data)
Definition: Blackfire.php:41
getPeakMemoryUsage()
Returns the peak memory usage in bytes.
Definition: Profile.php:119
getDuration()
Returns the duration in microseconds.
Definition: Profile.php:89
getMemoryUsage()
Returns the memory usage in bytes.
Definition: Profile.php:109
if($format !==null) $name
Definition: metadata.php:146