C:\xampp2_not used\phpMyAdmin\vendor\twig\twig\lib\Twig\Profiler\Dumper\Blackfire.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

/*
 * This file is part of Twig.
 *
 * (c) Fabien Potencier
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * @author Fabien Potencier <fabien@symfony.com>
 *
 * @final
 */
class Twig_Profiler_Dumper_Blackfire
{
    public function 
dump(Twig_Profiler_Profile $profile)
    {
        
$data = [];
        
$this->dumpProfile('main()'$profile$data);
        
$this->dumpChildren('main()'$profile$data);

        
$start sprintf('%f'microtime(true));
        
$str = <<<EOF
file-format: BlackfireProbe
cost-dimensions: wt mu pmu
request-start: 
{$start}


EOF;

        foreach (
$data as $name => $values) {
            
$str .= "{$name}//{$values['ct']} {$values['wt']} {$values['mu']} {$values['pmu']}\n";
        }

        return 
$str;
    }

    private function 
dumpChildren($parentTwig_Profiler_Profile $profile, &$data)
    {
        foreach (
$profile as $p) {
            if (
$p->isTemplate()) {
                
$name $p->getTemplate();
            } else {
                
$name sprintf('%s::%s(%s)'$p->getTemplate(), $p->getType(), $p->getName());
            }
            
$this->dumpProfile(sprintf('%s==>%s'$parent$name), $p$data);
            
$this->dumpChildren($name$p$data);
        }
    }

    private function 
dumpProfile($edgeTwig_Profiler_Profile $profile, &$data)
    {
        if (isset(
$data[$edge])) {
            ++
$data[$edge]['ct'];
            
$data[$edge]['wt'] += floor($profile->getDuration() * 1000000);
            
$data[$edge]['mu'] += $profile->getMemoryUsage();
            
$data[$edge]['pmu'] += $profile->getPeakMemoryUsage();
        } else {
            
$data[$edge] = [
                
'ct' => 1,
                
'wt' => floor($profile->getDuration() * 1000000),
                
'mu' => $profile->getMemoryUsage(),
                
'pmu' => $profile->getPeakMemoryUsage(),
            ];
        }
    }
}

class_alias('Twig_Profiler_Dumper_Blackfire''Twig\Profiler\Dumper\BlackfireDumper'false);
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586