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
27 file-format: BlackfireProbe
28 cost-dimensions: wt mu pmu
29 request-start: {$start}
30 
31 
32 EOF;
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 
72 class_alias('Twig_Profiler_Dumper_Blackfire', 'Twig\Profiler\Dumper\BlackfireDumper', false);
dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
Definition: Blackfire.php:54
getPeakMemoryUsage()
Returns the peak memory usage in bytes.
Definition: Profile.php:119
getMemoryUsage()
Returns the memory usage in bytes.
Definition: Profile.php:109
if($format !==null) $name
Definition: metadata.php:146
dumpChildren($parent, Twig_Profiler_Profile $profile, &$data)
Definition: Blackfire.php:41
dump(Twig_Profiler_Profile $profile)
Definition: Blackfire.php:19
Reload workbook from saved file
Create styles array
The data for the language used.
Write to Excel2007 format
getDuration()
Returns the duration in microseconds.
Definition: Profile.php:89
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92