overwrite profiling methods to get a more accurate profiling
This commit is contained in:
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);
|
||||
}
|
Reference in New Issue
Block a user