From a6317f7d9d6950665587f10b051f6403fc05067b Mon Sep 17 00:00:00 2001 From: Mzhelskiy Maxim Date: Sat, 5 Jun 2010 12:24:37 +0000 Subject: [PATCH] =?UTF-8?q?fix=20+=20=D0=B2=D1=8B=D0=BD=D0=BE=D1=81=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=81=D1=82=D0=B8=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B8=D0=B7=D0=B2=D0=BE=D0=B4=D0=B8=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=B8=D0=B7?= =?UTF-8?q?=20index.php=20=D0=B2=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D0=B9=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hooks/HookStatisticsPerformance.class.php | 42 +++++++++++++++ engine/classes/Engine.class.php | 6 +++ engine/classes/Hook.class.php | 10 +++- index.php | 51 +------------------ .../classes/hooks/HookProfiler.class.php | 39 ++++++++++++++ .../profiler/templates/skin/default/link.tpl | 4 ++ .../templates/skin/developer/link.tpl | 4 ++ plugins/profiler/templates/skin/new/link.tpl | 4 ++ templates/skin/developer/header_top.tpl | 9 ++-- .../skin/developer/statistics_performance.tpl | 38 ++++++++++++++ templates/skin/new/statistics_performance.tpl | 38 ++++++++++++++ 11 files changed, 187 insertions(+), 58 deletions(-) create mode 100644 classes/hooks/HookStatisticsPerformance.class.php create mode 100644 plugins/profiler/classes/hooks/HookProfiler.class.php create mode 100644 plugins/profiler/templates/skin/default/link.tpl create mode 100644 plugins/profiler/templates/skin/developer/link.tpl create mode 100644 plugins/profiler/templates/skin/new/link.tpl create mode 100644 templates/skin/developer/statistics_performance.tpl create mode 100644 templates/skin/new/statistics_performance.tpl diff --git a/classes/hooks/HookStatisticsPerformance.class.php b/classes/hooks/HookStatisticsPerformance.class.php new file mode 100644 index 00000000..ded85b8d --- /dev/null +++ b/classes/hooks/HookStatisticsPerformance.class.php @@ -0,0 +1,42 @@ +AddHook('template_body_end','Statistics',__CLASS__,-1000); + } + + public function Statistics() { + $oEngine=Engine::getInstance(); + + $iTimeInit=$oEngine->GetTimeInit(); + $iTimeFull=round(microtime(true)-$iTimeInit,3); + $this->Viewer_Assign('iTimeFullPerformance',$iTimeFull); + + $aStats=$oEngine->getStats(); + $aStats['cache']['time']=round($aStats['cache']['time'],5); + $this->Viewer_Assign('aStatsPerformance',$aStats); + + $this->Viewer_Assign('bIsShowStatsPerformance',Router::GetIsShowStats()); + return $this->Viewer_Fetch(Plugin::GetTemplatePath(__CLASS__).'statistics_performance.tpl'); + } +} +?> \ No newline at end of file diff --git a/engine/classes/Engine.class.php b/engine/classes/Engine.class.php index 074fccbc..38263ffb 100644 --- a/engine/classes/Engine.class.php +++ b/engine/classes/Engine.class.php @@ -40,6 +40,7 @@ class Engine extends Object { protected $aPlugins=array(); protected $aConfigModule; public $iTimeLoadModule=0; + protected $iTimeInit=null; /** * Массив содержит меппер кастомизации сущностей @@ -53,6 +54,7 @@ class Engine extends Object { * */ protected function __construct() { + $this->iTimeInit=microtime(true); if (get_magic_quotes_gpc()) { func_stripslashes($_REQUEST); func_stripslashes($_GET); @@ -394,6 +396,10 @@ class Engine extends Object { public function getStats() { return array('sql'=>$this->Database_GetStats(),'cache'=>$this->Cache_GetStats(),'engine'=>array('time_load_module'=>round($this->iTimeLoadModule,3))); } + + public function GetTimeInit() { + return $this->iTimeInit; + } /** * Ставим хук на вызов неизвестного метода и считаем что хотели вызвать метод какого либо модуля diff --git a/engine/classes/Hook.class.php b/engine/classes/Hook.class.php index b5c69ba0..91b816c4 100644 --- a/engine/classes/Hook.class.php +++ b/engine/classes/Hook.class.php @@ -25,11 +25,17 @@ abstract class Hook extends Object { } - protected function AddHook($sName,$sCallBack,$sClassNameHook,$iPriority=1) { + protected function AddHook($sName,$sCallBack,$sClassNameHook=null,$iPriority=1) { + if (is_null($sClassNameHook)) { + $sClassNameHook=get_class($this); + } $this->Hook_AddExecHook($sName,$sCallBack,$iPriority,array('sClassName'=>$sClassNameHook)); } - protected function AddDelegateHook($sName,$sCallBack,$sClassNameHook,$iPriority=1) { + protected function AddDelegateHook($sName,$sCallBack,$sClassNameHook=null,$iPriority=1) { + if (is_null($sClassNameHook)) { + $sClassNameHook=get_class($this); + } $this->Hook_AddDelegateHook($sName,$sCallBack,$iPriority,array('sClassName'=>$sClassNameHook)); } diff --git a/index.php b/index.php index 5cc14e11..f1c28969 100644 --- a/index.php +++ b/index.php @@ -20,8 +20,6 @@ define('LS_VERSION','0.4.1'); define('SYS_HACKER_CONSOLE',false); header('Content-Type: text/html; charset=utf-8'); -$t1=microtime(true); - set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__)); chdir(dirname(__FILE__)); @@ -35,52 +33,5 @@ $iTimeId=$oProfiler->Start('full_time'); $oRouter=Router::getInstance(); $oRouter->Exec(); -$oEngine=Engine::getInstance(); -$aStats=$oEngine->getStats(); -$t2=microtime(true); - $oProfiler->Stop($iTimeId); -?> - -User_GetUserCurrent(); -if (Router::GetIsShowStats() and $oUser and $oUser->isAdministrator()) { -?> -
-Statistics performance - - - - - - -
-
    -
  • - MySql
    -    query:
    -    time:


    -
  • -
-
-
    -
  • - Cache
    -    query:
    -             set:
    -             get:
    -    time: -
  • -
-
-
    -
  • - PHP
    -    time load modules:
    -    full time:


    -
  • -
-
-
-

Profiler: | Profiler reports

- \ No newline at end of file +?> \ No newline at end of file diff --git a/plugins/profiler/classes/hooks/HookProfiler.class.php b/plugins/profiler/classes/hooks/HookProfiler.class.php new file mode 100644 index 00000000..14126735 --- /dev/null +++ b/plugins/profiler/classes/hooks/HookProfiler.class.php @@ -0,0 +1,39 @@ +AddHook('template_body_end', 'Profiler'); + } + + /** + * Выводим HTML + * + */ + public function Profiler() { + return $this->Viewer_Fetch(Plugin::GetTemplatePath(__CLASS__).'link.tpl'); + } +} +?> \ No newline at end of file diff --git a/plugins/profiler/templates/skin/default/link.tpl b/plugins/profiler/templates/skin/default/link.tpl new file mode 100644 index 00000000..b736d469 --- /dev/null +++ b/plugins/profiler/templates/skin/default/link.tpl @@ -0,0 +1,4 @@ +

+ Profiler: {if $oConfig->GetValue('sys.logs.profiler')}On{else}Off{/if} | + Profiler reports +

\ No newline at end of file diff --git a/plugins/profiler/templates/skin/developer/link.tpl b/plugins/profiler/templates/skin/developer/link.tpl new file mode 100644 index 00000000..b736d469 --- /dev/null +++ b/plugins/profiler/templates/skin/developer/link.tpl @@ -0,0 +1,4 @@ +

+ Profiler: {if $oConfig->GetValue('sys.logs.profiler')}On{else}Off{/if} | + Profiler reports +

\ No newline at end of file diff --git a/plugins/profiler/templates/skin/new/link.tpl b/plugins/profiler/templates/skin/new/link.tpl new file mode 100644 index 00000000..b736d469 --- /dev/null +++ b/plugins/profiler/templates/skin/new/link.tpl @@ -0,0 +1,4 @@ +

+ Profiler: {if $oConfig->GetValue('sys.logs.profiler')}On{else}Off{/if} | + Profiler reports +

\ No newline at end of file diff --git a/templates/skin/developer/header_top.tpl b/templates/skin/developer/header_top.tpl index 6e05ffaf..bcb627e0 100644 --- a/templates/skin/developer/header_top.tpl +++ b/templates/skin/developer/header_top.tpl @@ -44,18 +44,15 @@ {/if} - - {* *} +

LiveStreet

- - {* *} +