Skip to content

Commit a30fd6f

Browse files
author
Yongcheng Chen
committed
init
0 parents  commit a30fd6f

File tree

133 files changed

+2169
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+2169
-0
lines changed
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.

.phpintel/index

6 Bytes
Binary file not shown.
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/*
3+
* This file is part of the Magento2DebugBar package.
4+
*
5+
* (c) Yongcheng Chen <yongcheng.chen@live.com>
6+
*
7+
* For the full copyright and license information, please view the README.md
8+
* file that was distributed with this source code.
9+
*/
10+
namespace Yong\Magento2DebugBar\Block\Collector;
11+
12+
use DebugBar\DataCollector\TimeDataCollector;
13+
14+
class ControllerCollector extends TimeDataCollector
15+
{
16+
public function addController($name, $params)
17+
{
18+
$time = microtime(true);
19+
$this->addMeasure($name, $time, $time, $params);
20+
}
21+
22+
public function collect()
23+
{
24+
$data = parent::collect();
25+
$data['nb_measures'] = count($data['measures']);
26+
27+
return $data;
28+
}
29+
30+
public function getName()
31+
{
32+
return 'controller';
33+
}
34+
35+
public function getWidgets()
36+
{
37+
return array(
38+
"controllers" => array(
39+
"icon" => "tasks",
40+
"widget" => "PhpDebugBar.Widgets.TimelineWidget",
41+
"map" => "controller",
42+
"default" => "{}",
43+
),
44+
'controllers:badge' => array(
45+
'map' => 'controller.nb_measures',
46+
'default' => 0,
47+
),
48+
);
49+
}
50+
}

Block/Collector/EventCollector.php

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/*
3+
* This file is part of the Magento2DebugBar package.
4+
*
5+
* (c) Yongcheng Chen <yongcheng.chen@live.com>
6+
*
7+
* For the full copyright and license information, please view the README.md
8+
* file that was distributed with this source code.
9+
*/
10+
namespace Yong\Magento2DebugBar\Block\Collector;
11+
12+
use DebugBar\DataCollector\TimeDataCollector;
13+
use Yong\Magento2DebugBar\Block\ValueExporter;
14+
15+
class EventCollector extends TimeDataCollector
16+
{
17+
/** @var Dispatcher */
18+
protected $events;
19+
20+
/** @var ValueExporter */
21+
protected $exporter;
22+
23+
public function __construct()
24+
{
25+
parent::__construct();
26+
$this->exporter = new ValueExporter();
27+
}
28+
29+
public function addEvent($name, $starttime, $endtime, $data)
30+
{
31+
$params = [];
32+
foreach ($data as $key => $value) {
33+
$params[$key] = $this->exporter->exportValue($value);
34+
}
35+
36+
$this->addMeasure($name, $starttime, $endtime, $params);
37+
}
38+
39+
public function collect()
40+
{
41+
$data = parent::collect();
42+
$data['nb_measures'] = count($data['measures']);
43+
44+
return $data;
45+
}
46+
47+
public function getName()
48+
{
49+
return 'event';
50+
}
51+
52+
public function getWidgets()
53+
{
54+
return array(
55+
"events" => array(
56+
"icon" => "tasks",
57+
"widget" => "PhpDebugBar.Widgets.TimelineWidget",
58+
"map" => "event",
59+
"default" => "{}",
60+
),
61+
'events:badge' => array(
62+
'map' => 'event.nb_measures',
63+
'default' => 0,
64+
),
65+
);
66+
}
67+
}

Block/Collector/ModelCollector.php

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/*
3+
* This file is part of the Magento2DebugBar package.
4+
*
5+
* (c) Yongcheng Chen <yongcheng.chen@live.com>
6+
*
7+
* For the full copyright and license information, please view the README.md
8+
* file that was distributed with this source code.
9+
*/
10+
namespace Yong\Magento2DebugBar\Block\Collector;
11+
12+
use DebugBar\DataCollector\TimeDataCollector;
13+
14+
class ModelCollector extends TimeDataCollector
15+
{
16+
/** @var Dispatcher */
17+
protected $model;
18+
19+
public function addModel($name, $params)
20+
{
21+
$time = microtime(true);
22+
$this->addMeasure($name, $time, $time, $params);
23+
}
24+
25+
public function collect()
26+
{
27+
$data = parent::collect();
28+
$data['nb_measures'] = count($data['measures']);
29+
30+
return $data;
31+
}
32+
33+
public function getName()
34+
{
35+
return 'model';
36+
}
37+
38+
public function getWidgets()
39+
{
40+
return array(
41+
"models" => array(
42+
"icon" => "tasks",
43+
"widget" => "PhpDebugBar.Widgets.TimelineWidget",
44+
"map" => "model",
45+
"default" => "{}",
46+
),
47+
'models:badge' => array(
48+
'map' => 'model.nb_measures',
49+
'default' => 0,
50+
),
51+
);
52+
}
53+
}

Block/Collector/ProfilerCollector.php

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
/*
3+
* This file is part of the Magento2DebugBar package.
4+
*
5+
* (c) Yongcheng Chen <yongcheng.chen@live.com>
6+
*
7+
* For the full copyright and license information, please view the README.md
8+
* file that was distributed with this source code.
9+
*/
10+
namespace Yong\Magento2DebugBar\Block\Collector;
11+
12+
use DebugBar\DataCollector\TimeDataCollector;
13+
use Magento\Framework\Profiler\DriverInterface;
14+
use Magento\Framework\Profiler\Driver\Standard\Stat;
15+
16+
class ProfilerCollector extends TimeDataCollector implements DriverInterface
17+
{
18+
private $_stat;
19+
private $tabcount;
20+
private $levels;
21+
public function __construct() {
22+
$this->_stat = new Stat();
23+
$this->tabcount = 1;
24+
$this->levels = [];
25+
}
26+
27+
public function collect()
28+
{
29+
$timers = $this->_stat->getFilteredTimerIds();
30+
$time = microtime(true);
31+
32+
foreach ($timers as $timerId) {
33+
$params = $this->_stat->get($timerId);
34+
$name = $timerId;
35+
if ($this->levels[$timerId] > 1) {
36+
$name = str_repeat(' ', $this->levels[$timerId] -1 ) . 'L' . ($this->levels[$timerId]-1) . '--' . $timerId;
37+
}
38+
$this->addMeasure($name, $time - $params[Stat::TIME], $time,
39+
[
40+
'REALMEM'=>$params[Stat::REALMEM],
41+
'EMALLOC'=>$params[Stat::EMALLOC],
42+
'COUNT'=>$params[Stat::COUNT]
43+
]);
44+
}
45+
$data = parent::collect();
46+
$data['nb_measures'] = count($data['measures']);
47+
48+
return $data;
49+
}
50+
51+
public function getName()
52+
{
53+
return 'profiler';
54+
}
55+
56+
public function getWidgets()
57+
{
58+
return array(
59+
"profilers" => array(
60+
"icon" => "tasks",
61+
"widget" => "PhpDebugBar.Widgets.TimelineWidget",
62+
"map" => "profiler",
63+
"default" => "{}",
64+
),
65+
'profilers:badge' => array(
66+
'map' => 'profiler.nb_measures',
67+
'default' => 0,
68+
),
69+
);
70+
}
71+
72+
/**
73+
* Start timer
74+
*
75+
* @param string $timerId
76+
* @param array|null $tags
77+
* @return void
78+
*/
79+
public function start($timerId, array $tags = null) {
80+
$this->_stat->start($timerId, microtime(true), memory_get_usage(true), memory_get_usage());
81+
$this->levels[$timerId] = $this->tabcount++;
82+
}
83+
84+
/**
85+
* Stop timer
86+
*
87+
* @param string $timerId
88+
* @return void
89+
*/
90+
public function stop($timerId){
91+
$this->_stat->stop($timerId, microtime(true), memory_get_usage(true), memory_get_usage());
92+
$this->tabcount --;
93+
$this->levels[$timerId] = $this->tabcount;
94+
}
95+
96+
/**
97+
* Clear collected statistics for specified timer or for whole profiler if timer name is omitted.
98+
*
99+
* @param string|null $timerId
100+
* @return void
101+
*/
102+
public function clear($timerId = null){
103+
$this->_stat->clear($timerId);
104+
}
105+
}

0 commit comments

Comments
 (0)