Merge remote-tracking branch 'remotes/origin/dev_profiling' into main
This commit is contained in:
commit
d20aeeb661
@ -16,9 +16,9 @@ declare(strict_types=1);
|
|||||||
namespace D3\DebugBar\Application\Component;
|
namespace D3\DebugBar\Application\Component;
|
||||||
|
|
||||||
use D3\DebugBar\Application\Models\Collectors\SmartyCollector;
|
use D3\DebugBar\Application\Models\Collectors\SmartyCollector;
|
||||||
|
use D3\DebugBar\Application\Models\TimeDataCollectorHandler;
|
||||||
use DebugBar\Bridge\DoctrineCollector;
|
use DebugBar\Bridge\DoctrineCollector;
|
||||||
use DebugBar\Bridge\MonologCollector;
|
use DebugBar\Bridge\MonologCollector;
|
||||||
use DebugBar\DataCollector\TimeDataCollector;
|
|
||||||
use DebugBar\DebugBarException;
|
use DebugBar\DebugBarException;
|
||||||
use DebugBar\JavascriptRenderer;
|
use DebugBar\JavascriptRenderer;
|
||||||
use DebugBar\StandardDebugBar;
|
use DebugBar\StandardDebugBar;
|
||||||
@ -26,7 +26,6 @@ use Doctrine\DBAL\Logging\DebugStack;
|
|||||||
use OxidEsales\Eshop\Core\Controller\BaseController;
|
use OxidEsales\Eshop\Core\Controller\BaseController;
|
||||||
use OxidEsales\Eshop\Core\DatabaseProvider;
|
use OxidEsales\Eshop\Core\DatabaseProvider;
|
||||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
@ -99,16 +98,6 @@ class DebugBarComponent extends BaseController
|
|||||||
return new SmartyCollector(Registry::getUtilsView()->getSmarty());
|
return new SmartyCollector(Registry::getUtilsView()->getSmarty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function render()
|
|
||||||
{
|
|
||||||
$this->getParent()->addTplParam('debugBarRenderer', $this->debugBarRenderer);
|
|
||||||
$this->getParent()->addTplParam('debugBarComponent', $this);
|
|
||||||
return parent::render();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $object
|
* @param $object
|
||||||
* @param $propName
|
* @param $propName
|
||||||
@ -137,22 +126,25 @@ class DebugBarComponent extends BaseController
|
|||||||
$debugbar->addCollector($this->getSmartyCollector());
|
$debugbar->addCollector($this->getSmartyCollector());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addTimelineMessures()
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addTimelineMessures(): void
|
||||||
{
|
{
|
||||||
/** @var TimeDataCollector $tCollector */
|
$collectors = $this->debugBar->getCollectors();
|
||||||
$tCollector = $this->debugBar['time'];
|
$collectors['time'] = TimeDataCollectorHandler::getInstance();
|
||||||
|
|
||||||
global $aStartTimes;
|
$reflection = new ReflectionClass($this->debugBar);
|
||||||
global $aProfileTimes;
|
$property = $reflection->getProperty('collectors');
|
||||||
global $executionCounts;
|
$property->setAccessible(true);
|
||||||
foreach ($aProfileTimes as $label => $recordedTime) {
|
$property->setValue($this->debugBar, $collectors);
|
||||||
for ($i = 0; $i < $executionCounts[$label]; $i++) {
|
|
||||||
$tCollector->addMeasure(
|
|
||||||
$label,
|
|
||||||
$aStartTimes[$label],
|
|
||||||
$aStartTimes[$label] + $aProfileTimes[$label] / $executionCounts[$label]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return JavascriptRenderer
|
||||||
|
*/
|
||||||
|
public function getRenderer(): JavascriptRenderer
|
||||||
|
{
|
||||||
|
return $this->debugBarRenderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
35
Application/Models/TimeDataCollectorHandler.php
Normal file
35
Application/Models/TimeDataCollectorHandler.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* https://www.d3data.de
|
||||||
|
*
|
||||||
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||||
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||||
|
* @link https://www.oxidmodule.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace D3\DebugBar\Application\Models;
|
||||||
|
|
||||||
|
use DebugBar\DataCollector\TimeDataCollector;
|
||||||
|
|
||||||
|
class TimeDataCollectorHandler
|
||||||
|
{
|
||||||
|
/** @var TimeDataCollector */
|
||||||
|
private static $instance = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return TimeDataCollector
|
||||||
|
*/
|
||||||
|
public static function getInstance(): TimeDataCollector
|
||||||
|
{
|
||||||
|
if (self::$instance === null) {
|
||||||
|
self::$instance = new TimeDataCollector();
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
[{$smarty.block.parent}]
|
|
||||||
|
|
||||||
[{$debugBarRenderer->renderHead()}]
|
|
||||||
[{$debugBarComponent->addTimelineMessures()}]
|
|
||||||
[{$debugBarRenderer->render()}]
|
|
@ -20,17 +20,11 @@ use OxidEsales\Eshop\Core\Registry;
|
|||||||
|
|
||||||
class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
||||||
{
|
{
|
||||||
/**
|
public function __construct()
|
||||||
* @param null $controllerKey
|
|
||||||
* @param null $function
|
|
||||||
* @param null $parameters
|
|
||||||
* @param null $viewsChain
|
|
||||||
*/
|
|
||||||
public function start ($controllerKey = null, $function = null, $parameters = null, $viewsChain = null)
|
|
||||||
{
|
{
|
||||||
$this->_d3AddDebugBarComponent();
|
$this->_d3AddDebugBarComponent();
|
||||||
|
|
||||||
parent::start( $controllerKey, $function, $parameters, $viewsChain);
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,4 +45,15 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
|||||||
Registry::getConfig()->setConfigParam('aUserComponentNames', $userComponentNames);
|
Registry::getConfig()->setConfigParam('aUserComponentNames', $userComponentNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
if (!isAdmin()) {
|
||||||
|
/** @var DebugBarComponent $debugBarComponent */
|
||||||
|
$debugBarComponent = Registry::getConfig()->getActiveView()->getComponent(DebugBarComponent::class);
|
||||||
|
echo $debugBarComponent->getRenderer()->renderHead();
|
||||||
|
$debugBarComponent->addTimelineMessures();
|
||||||
|
echo $debugBarComponent->getRenderer()->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
57
Modules/functions.php
Normal file
57
Modules/functions.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*
|
||||||
|
* https://www.d3data.de
|
||||||
|
*
|
||||||
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||||
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||||
|
* @link https://www.oxidmodule.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
function startProfile($sProfileName)
|
||||||
|
{
|
||||||
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
$trace[0] = $sProfileName;
|
||||||
|
$hash = md5(serialize($trace)).'-'.$sProfileName;
|
||||||
|
|
||||||
|
$timeDataCollector = \D3\DebugBar\Application\Models\TimeDataCollectorHandler::getInstance();
|
||||||
|
$timeDataCollector->startMeasure($hash, $sProfileName);
|
||||||
|
|
||||||
|
global $aStartTimes;
|
||||||
|
global $executionCounts;
|
||||||
|
if (!isset($executionCounts[$sProfileName])) {
|
||||||
|
$executionCounts[$sProfileName] = 0;
|
||||||
|
}
|
||||||
|
if (!isset($aStartTimes[$sProfileName])) {
|
||||||
|
$aStartTimes[$sProfileName] = 0;
|
||||||
|
}
|
||||||
|
$executionCounts[$sProfileName]++;
|
||||||
|
$aStartTimes[$sProfileName] = microtime(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopProfile($sProfileName)
|
||||||
|
{
|
||||||
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
$trace[0] = $sProfileName;
|
||||||
|
$hash = md5(serialize($trace)).'-'.$sProfileName;
|
||||||
|
|
||||||
|
$timeDataCollector = \D3\DebugBar\Application\Models\TimeDataCollectorHandler::getInstance();
|
||||||
|
$timeDataCollector->stopMeasure($hash);
|
||||||
|
|
||||||
|
|
||||||
|
global $aStartTimes;
|
||||||
|
global $executionCounts;
|
||||||
|
if (!isset($executionCounts[$sProfileName])) {
|
||||||
|
$executionCounts[$sProfileName] = 0;
|
||||||
|
}
|
||||||
|
if (!isset($aStartTimes[$sProfileName])) {
|
||||||
|
$aStartTimes[$sProfileName] = 0;
|
||||||
|
}
|
||||||
|
$executionCounts[$sProfileName]++;
|
||||||
|
$aStartTimes[$sProfileName] = microtime(true);
|
||||||
|
}
|
@ -23,7 +23,13 @@ Please enter the following section in the `composer.json` of your project:
|
|||||||
"extra": {
|
"extra": {
|
||||||
"ajgl-symlinks": {
|
"ajgl-symlinks": {
|
||||||
"maximebf/debugbar": {
|
"maximebf/debugbar": {
|
||||||
"src/DebugBar/Resources": { "source/out/debugbar".
|
"src/DebugBar/Resources": "source/out/debugbar"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"enable-patching": "true",
|
||||||
|
"patches": {
|
||||||
|
"oxid-esales/oxideshop-ce": {
|
||||||
|
"Add overridable functions for advanced profiling in Debug Bar": "https://git.d3data.de/D3Public/DebugBar/raw/branch/patches/overridablefunctions.patch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
README.md
10
README.md
@ -25,6 +25,12 @@ Bitte tragen Sie den folgenden Abschnitt in die `composer.json` Ihres Projektes
|
|||||||
"maximebf/debugbar": {
|
"maximebf/debugbar": {
|
||||||
"src/DebugBar/Resources": "source/out/debugbar"
|
"src/DebugBar/Resources": "source/out/debugbar"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"enable-patching": "true",
|
||||||
|
"patches": {
|
||||||
|
"oxid-esales/oxideshop-ce": {
|
||||||
|
"Add overridable functions for advanced profiling in Debug Bar": "https://git.d3data.de/D3Public/DebugBar/raw/branch/patches/overridablefunctions.patch"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -40,6 +46,10 @@ Sofern nötig, bestätigen Sie bitte, dass Sie `composer-symlinker` erlauben, Co
|
|||||||
|
|
||||||
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
|
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
|
||||||
|
|
||||||
|
```
|
||||||
|
include './modules/d3/debugbar/Modules/functions.php';
|
||||||
|
```
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
Siehe [CHANGELOG](CHANGELOG.md) für weitere Informationen.
|
Siehe [CHANGELOG](CHANGELOG.md) für weitere Informationen.
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
"php": ">=7.3",
|
"php": ">=7.3",
|
||||||
"oxid-esales/oxideshop-ce": "6.8 - 6.10",
|
"oxid-esales/oxideshop-ce": "6.8 - 6.10",
|
||||||
"maximebf/debugbar": "^1.18",
|
"maximebf/debugbar": "^1.18",
|
||||||
"ajgl/composer-symlinker": "^0.3.1"
|
"ajgl/composer-symlinker": "^0.3.1",
|
||||||
|
"cweagans/composer-patches": "^1.7.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"php": "^7.4",
|
"php": "^7.4",
|
||||||
|
@ -42,11 +42,5 @@ $aModule = [
|
|||||||
'events' => [],
|
'events' => [],
|
||||||
'templates' => [],
|
'templates' => [],
|
||||||
'settings' => [],
|
'settings' => [],
|
||||||
'blocks' => [
|
'blocks' => [],
|
||||||
[
|
|
||||||
'template' => 'layout/footer.tpl',
|
|
||||||
'block' => 'footer_main',
|
|
||||||
'file' => 'Application/views/blocks/layout/footer_main_debugbar.tpl'
|
|
||||||
]
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user