mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
N°3985 - Performance checks on the back end
This commit is contained in:
@@ -147,6 +147,7 @@ class AjaxPage extends WebPage implements iTabbedPage
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
$oKpi = new ExecutionKPI();
|
||||
$s_captured_output = $this->ob_get_clean_safe();
|
||||
|
||||
if (!empty($this->sContentType)) {
|
||||
@@ -198,9 +199,10 @@ class AjaxPage extends WebPage implements iTabbedPage
|
||||
|
||||
$aData['aBlockParams'] = $this->GetBlockParams();
|
||||
|
||||
$oKpi->ComputeAndReport(get_class($this).' prepare output');
|
||||
$oKpi = new ExecutionKPI();
|
||||
$oTwigEnv = TwigHelper::GetTwigEnvironment(BlockRenderer::TWIG_BASE_PATH, BlockRenderer::TWIG_ADDITIONAL_PATHS);
|
||||
// Render final TWIG into global HTML
|
||||
$oKpi = new ExecutionKPI();
|
||||
$sHtml = TwigHelper::RenderTemplate($oTwigEnv, $aData, $this->GetTemplateRelPath());
|
||||
$oKpi->ComputeAndReport('TWIG rendering');
|
||||
|
||||
@@ -208,8 +210,7 @@ class AjaxPage extends WebPage implements iTabbedPage
|
||||
$oKpi = new ExecutionKPI();
|
||||
echo $sHtml;
|
||||
$oKpi->ComputeAndReport('Echoing ('.round(strlen($sHtml) / 1024).' Kb)');
|
||||
|
||||
return;
|
||||
ExecutionKPI::ReportStats();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,9 +54,7 @@ class CSVPage extends WebPage
|
||||
if (class_exists('DBSearch')) {
|
||||
DBSearch::RecordQueryTrace();
|
||||
}
|
||||
if (class_exists('ExecutionKPI')) {
|
||||
ExecutionKPI::ReportStats();
|
||||
}
|
||||
ExecutionKPI::ReportStats();
|
||||
}
|
||||
|
||||
public function small_p($sText)
|
||||
|
||||
@@ -32,6 +32,7 @@ class DownloadPage extends AjaxPage
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
$oKpi = new ExecutionKPI();
|
||||
if (!empty($this->sContentType)) {
|
||||
$this->add_header('Content-type: '.$this->sContentType);
|
||||
}
|
||||
@@ -48,8 +49,10 @@ class DownloadPage extends AjaxPage
|
||||
} else {
|
||||
$sContent = $this->sContent;
|
||||
}
|
||||
$oKpi->ComputeAndReport(get_class($this).' prepare output');
|
||||
$oKpi = new ExecutionKPI();
|
||||
echo $sContent;
|
||||
$oKpi->ComputeAndReport('Echoing ('.round(strlen($sContent) / 1024).' Kb)');
|
||||
ExecutionKPI::ReportStats();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ class JsonPage extends WebPage
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
$oKpi = new ExecutionKPI();
|
||||
$this->add_header('Content-type: application/json');
|
||||
|
||||
foreach ($this->a_headers as $s_header) {
|
||||
@@ -91,11 +92,13 @@ class JsonPage extends WebPage
|
||||
'data' => $this->aData,
|
||||
'scripts' => $aScripts,
|
||||
];
|
||||
$oKpi->ComputeAndReport(get_class($this).' prepare output');
|
||||
|
||||
$oKpi = new ExecutionKPI();
|
||||
$sJSON = json_encode($aJson);
|
||||
echo $sJSON;
|
||||
$oKpi->ComputeAndReport('Echoing ('.round(strlen($sJSON) / 1024).' Kb)');
|
||||
ExecutionKPI::ReportStats();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\Helper\Session;
|
||||
use Combodo\iTop\Application\TwigBase\Twig\TwigHelper;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory;
|
||||
@@ -178,10 +179,9 @@ class WebPage implements Page
|
||||
*/
|
||||
public function AddSessionMessages(string $sMessageKey, array $aRanks = [], array $aMessages = []): void
|
||||
{
|
||||
if (array_key_exists('obj_messages', $_SESSION) && array_key_exists($sMessageKey,
|
||||
$_SESSION['obj_messages'])) {
|
||||
if (is_array(Session::Get(['obj_messages', $sMessageKey]))) {
|
||||
$aReadMessages = [];
|
||||
foreach ($_SESSION['obj_messages'][$sMessageKey] as $sMessageId => $aMessageData) {
|
||||
foreach (Session::Get(['obj_messages', $sMessageKey]) as $aMessageData) {
|
||||
if (!in_array($aMessageData['message'], $aReadMessages)) {
|
||||
$aReadMessages[] = $aMessageData['message'];
|
||||
$aRanks[] = $aMessageData['rank'];
|
||||
@@ -202,7 +202,7 @@ class WebPage implements Page
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($_SESSION['obj_messages'][$sMessageKey]);
|
||||
Session::Unset(['obj_messages', $sMessageKey]);
|
||||
}
|
||||
array_multisort($aRanks, $aMessages);
|
||||
foreach ($aMessages as $oMessage) {
|
||||
@@ -1153,6 +1153,7 @@ JS;
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
$oKpi = new ExecutionKPI();
|
||||
// Send headers
|
||||
foreach ($this->a_headers as $sHeader) {
|
||||
header($sHeader);
|
||||
@@ -1206,10 +1207,11 @@ JS;
|
||||
|
||||
// Favicon
|
||||
$aData['aPage']['sFaviconUrl'] = $this->GetFaviconAbsoluteUrl();
|
||||
$oKpi->ComputeAndReport(get_class($this).' prepare output');
|
||||
|
||||
$oKpi = new ExecutionKPI();
|
||||
$oTwigEnv = TwigHelper::GetTwigEnvironment(BlockRenderer::TWIG_BASE_PATH, BlockRenderer::TWIG_ADDITIONAL_PATHS);
|
||||
// Render final TWIG into global HTML
|
||||
$oKpi = new ExecutionKPI();
|
||||
$sHtml = TwigHelper::RenderTemplate($oTwigEnv, $aData, $this->GetTemplateRelPath());
|
||||
$oKpi->ComputeAndReport('TWIG rendering');
|
||||
|
||||
@@ -1221,9 +1223,7 @@ JS;
|
||||
if (class_exists('DBSearch')) {
|
||||
DBSearch::RecordQueryTrace();
|
||||
}
|
||||
if (class_exists('ExecutionKPI')) {
|
||||
ExecutionKPI::ReportStats();
|
||||
}
|
||||
ExecutionKPI::ReportStats();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,6 +50,8 @@ class XMLPage extends WebPage
|
||||
{
|
||||
if (!$this->m_bPassThrough)
|
||||
{
|
||||
$oKpi = new ExecutionKPI();
|
||||
|
||||
// Get the unexpected output but do nothing with it
|
||||
$sTrash = $this->ob_get_clean_safe();
|
||||
|
||||
@@ -60,11 +62,15 @@ class XMLPage extends WebPage
|
||||
{
|
||||
header($s_header);
|
||||
}
|
||||
$oKpi->ComputeAndReport(get_class($this).' prepare output');
|
||||
$oKpi = new ExecutionKPI();
|
||||
echo $this->s_content;
|
||||
$oKpi->ComputeAndReport('Echoing ('.round(strlen($this->s_content) / 1024).' Kb)');
|
||||
}
|
||||
if (class_exists('DBSearch')) {
|
||||
DBSearch::RecordQueryTrace();
|
||||
}
|
||||
ExecutionKPI::ReportStats();
|
||||
}
|
||||
|
||||
public function add($sText)
|
||||
|
||||
@@ -780,6 +780,8 @@ HTML;
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
$oKpi = new ExecutionKPI();
|
||||
|
||||
// Data to be passed to the view
|
||||
$aData = [];
|
||||
|
||||
@@ -886,6 +888,7 @@ HTML;
|
||||
header($sHeader);
|
||||
}
|
||||
}
|
||||
$oKpi->ComputeAndReport(get_class($this).' prepare output');
|
||||
|
||||
|
||||
// Render final TWIG into global HTML
|
||||
|
||||
Reference in New Issue
Block a user