2010-06-05 15:24:37 +03:00
|
|
|
|
<?php
|
2014-10-08 08:20:29 +03:00
|
|
|
|
/*
|
|
|
|
|
* LiveStreet CMS
|
|
|
|
|
* Copyright © 2013 OOO "ЛС-СОФТ"
|
|
|
|
|
*
|
|
|
|
|
* ------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* Official site: www.livestreetcms.com
|
|
|
|
|
* Contact e-mail: office@livestreetcms.com
|
|
|
|
|
*
|
|
|
|
|
* GNU General Public License, version 2:
|
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
|
*
|
|
|
|
|
* ------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* @link http://www.livestreetcms.com
|
|
|
|
|
* @copyright 2013 OOO "ЛС-СОФТ"
|
|
|
|
|
* @author Maxim Mzhelskiy <rus.engine@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
*/
|
2010-06-05 15:24:37 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Регистрация хука для вывода статистики производительности
|
|
|
|
|
*
|
2014-10-08 08:20:29 +03:00
|
|
|
|
* @package application.hooks
|
2012-05-04 13:45:34 +03:00
|
|
|
|
* @since 1.0
|
2010-06-05 15:24:37 +03:00
|
|
|
|
*/
|
2014-10-08 11:49:34 +03:00
|
|
|
|
class HookStatisticsPerformance extends Hook
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Регистрируем хуки
|
|
|
|
|
*/
|
|
|
|
|
public function RegisterHook()
|
|
|
|
|
{
|
|
|
|
|
$this->AddHook('template_body_end', 'Statistics', __CLASS__, -1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Обработка хука перед закрывающим тегом body
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function Statistics()
|
|
|
|
|
{
|
|
|
|
|
$oEngine = Engine::getInstance();
|
|
|
|
|
/**
|
|
|
|
|
* Подсчитываем время выполнения
|
|
|
|
|
*/
|
|
|
|
|
$iTimeInit = $oEngine->GetTimeInit();
|
|
|
|
|
$iTimeFull = round(microtime(true) - $iTimeInit, 3);
|
2014-10-22 17:56:53 +03:00
|
|
|
|
$this->Viewer_Assign('timeFullPerformance', $iTimeFull, true);
|
2014-10-08 11:49:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Получаем статистику по кешу и БД
|
|
|
|
|
*/
|
|
|
|
|
$aStats = $oEngine->getStats();
|
|
|
|
|
$aStats['cache']['time'] = round($aStats['cache']['time'], 5);
|
2014-10-22 17:56:53 +03:00
|
|
|
|
$this->Viewer_Assign('stats', $aStats, true);
|
2014-10-08 11:49:34 +03:00
|
|
|
|
$this->Viewer_Assign('bIsShowStatsPerformance', Router::GetIsShowStats());
|
|
|
|
|
/**
|
|
|
|
|
* В ответ рендерим шаблон статистики
|
|
|
|
|
*/
|
2014-10-22 17:56:53 +03:00
|
|
|
|
return $this->Viewer_Fetch('components/perfomance/performance.tpl');
|
2014-10-08 11:49:34 +03:00
|
|
|
|
}
|
2014-05-28 08:37:30 +03:00
|
|
|
|
}
|