コード例 #1
0
 public function __construct($profileConfig)
 {
     if (isset($profileConfig['visible']) && $profileConfig['visible']) {
         $this->visible = true;
     }
     parent::__construct($profileConfig);
 }
コード例 #2
0
ファイル: Profiler.class.php プロジェクト: narush/livestreet
 /**
  * Ограничиваем объект только одним экземпляром
  *
  * @return ProfilerSimple
  */
 public static function getInstance($sFileName = null, $bEnable = true)
 {
     if (isset(self::$oInstance)) {
         return self::$oInstance;
     } else {
         self::$oInstance = new self($sFileName, $bEnable);
         return self::$oInstance;
     }
 }
コード例 #3
0
 function __construct($params)
 {
     global $wgRequestTime, $wgRUstart;
     parent::__construct($params);
     if (!empty($wgRequestTime) && !empty($wgRUstart)) {
         $this->mWorkStack[] = array('-total', 0, $wgRequestTime, $this->getCpuTime($wgRUstart), 0, '');
     }
     $this->trace .= "Beginning extended trace: \n";
 }
コード例 #4
0
ファイル: Mysqlwrapper.php プロジェクト: olegverstka/kprf.dev
 function _performQuery($queryMain)
 {
     $this->_lastQuery = $queryMain;
     $this->_expandPlaceholders($queryMain, false);
     $oProfiler = ProfilerSimple::getInstance();
     $iTimeId = $oProfiler->Start('query', $queryMain[0]);
     $result = @mysql_query($queryMain[0], $this->link);
     $oProfiler->Stop($iTimeId);
     if ($result === false) {
         return $this->_setDbError($queryMain[0]);
     }
     if (!is_resource($result)) {
         if (preg_match('/^\\s* INSERT \\s+/six', $queryMain[0])) {
             // INSERT queries return generated ID.
             return @mysql_insert_id($this->link);
         }
         // Non-SELECT queries return number of affected rows, SELECT - resource.
         return @mysql_affected_rows($this->link);
     }
     return $result;
 }
コード例 #5
0
 /**
  * Вызывает метод нужного модуля
  *
  * @param string $sName Название метода в полном виде.
  * Например <pre>Module_Method</pre>
  * @param array $aArgs Список аргументов
  * @return mixed
  */
 public function _CallModule($sName, $aArgs)
 {
     list($oModule, $sModuleName, $sMethod) = $this->GetModule($sName);
     if (!method_exists($oModule, $sMethod)) {
         // comment for ORM testing
         //throw new Exception("The module has no required method: ".$sModuleName.'->'.$sMethod.'()');
     }
     /**
      * Замеряем время выполнения метода
      */
     $oProfiler = ProfilerSimple::getInstance();
     $iTimeId = $oProfiler->Start('callModule', $sModuleName . '->' . $sMethod . '()');
     $sModuleName = strtolower($sModuleName);
     $aResultHook = array();
     if (!in_array($sModuleName, array('plugin', 'hook'))) {
         $aResultHook = $this->_CallModule('Hook_Run', array('module_' . $sModuleName . '_' . strtolower($sMethod) . '_before', &$aArgs));
     }
     /**
      * Хук может делегировать результат выполнения метода модуля, сам метод при этом не выполняется, происходит только подмена результата
      */
     if (array_key_exists('delegate_result', $aResultHook)) {
         $result = $aResultHook['delegate_result'];
     } else {
         $aArgsRef = array();
         foreach ($aArgs as $key => $v) {
             $aArgsRef[] =& $aArgs[$key];
         }
         $result = call_user_func_array(array($oModule, $sMethod), $aArgsRef);
     }
     if (!in_array($sModuleName, array('plugin', 'hook'))) {
         $this->Hook_Run('module_' . $sModuleName . '_' . strtolower($sMethod) . '_after', array('result' => &$result, 'params' => $aArgs));
     }
     $oProfiler->Stop($iTimeId);
     return $result;
 }
コード例 #6
0
ファイル: index.php プロジェクト: lifecom/Huddlebuddle
<?php

/*-------------------------------------------------------
*
*   LiveStreet Engine Social Networking
*   Copyright © 2008 Mzhelskiy Maxim
*
*--------------------------------------------------------
*
*   Official site: www.livestreet.ru
*   Contact e-mail: rus.engine@gmail.com
*
*   GNU General Public License, version 2:
*   http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
header('Content-Type: text/html; charset=utf-8');
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__));
chdir(dirname(__FILE__));
// Получаем объект конфигурации
require_once "./config/loader.php";
require_once Config::Get('path.root.engine') . "/classes/Engine.class.php";
$oProfiler = ProfilerSimple::getInstance(Config::Get('path.root.server') . '/logs/' . Config::Get('sys.logs.profiler_file'), Config::Get('sys.logs.profiler'));
$iTimeId = $oProfiler->Start('full_time');
$oRouter = Router::getInstance();
$oRouter->Exec();
$oProfiler->Stop($iTimeId);
コード例 #7
0
ファイル: Router.class.php プロジェクト: narush/livestreet
 /**
  * Запускает на выполнение экшен
  * Может запускаться рекурсивно если в одном экшене стоит переадресация на другой
  *
  */
 public function ExecAction()
 {
     $this->DefineActionClass();
     /**
      * Сначала запускаем инициализирующий экшен
      */
     require_once Config::Get('path.root.server') . '/classes/actions/Init.class.php';
     $oActionInit = new Init($this->oEngine);
     $oActionInit->InitAction();
     $sActionClass = $this->DefineActionClass();
     /**
      * Определяем наличие делегата экшена
      */
     if ($aChain = $this->Plugin_GetDelegationChain('action', $sActionClass)) {
         if (!empty($aChain)) {
             $sActionClass = $aChain[0];
         }
     }
     self::$sActionClass = $sActionClass;
     /**
      * Если класс экешна начинается с Plugin*_, значит необходимо загрузить объект из указанного плагина
      */
     if (!preg_match('/^Plugin([\\w]+)_Action([\\w]+)$/i', $sActionClass, $aMatches)) {
         require_once Config::Get('path.root.server') . '/classes/actions/' . $sActionClass . '.class.php';
     } else {
         require_once Config::Get('path.root.server') . '/plugins/' . strtolower($aMatches[1]) . '/classes/actions/Action' . ucfirst($aMatches[2]) . '.class.php';
     }
     $sClassName = $sActionClass;
     $this->oAction = new $sClassName($this->oEngine, self::$sAction);
     /**
      * Инициализируем экшен
      */
     $this->Hook_Run("action_init_" . strtolower($sActionClass) . "_before");
     $sInitResult = $this->oAction->Init();
     $this->Hook_Run("action_init_" . strtolower($sActionClass) . "_after");
     if ($sInitResult === 'next') {
         $this->ExecAction();
     } else {
         /**
          * Замеряем время работы action`а
          */
         $oProfiler = ProfilerSimple::getInstance();
         $iTimeId = $oProfiler->Start('ExecAction', self::$sAction);
         $res = $this->oAction->ExecEvent();
         $this->Hook_Run("action_shutdown_" . strtolower($sActionClass) . "_before");
         $this->oAction->EventShutdown();
         $this->Hook_Run("action_shutdown_" . strtolower($sActionClass) . "_after");
         $oProfiler->Stop($iTimeId);
         if ($res === 'next') {
             $this->ExecAction();
         }
     }
 }
コード例 #8
0
ファイル: Engine.class.php プロジェクト: narush/livestreet
 /**
  * Вызывает метод нужного модуля
  *
  * @param string $sName
  * @param array $aArgs
  * @return unknown
  */
 public function _CallModule($sName, $aArgs)
 {
     list($oModule, $sModuleName, $sMethod) = $this->GetModule($sName);
     if (!method_exists($oModule, $sMethod)) {
         // comment for ORM testing
         //throw new Exception("The module has no required method: ".$sModuleName.'->'.$sMethod.'()');
     }
     $oProfiler = ProfilerSimple::getInstance();
     $iTimeId = $oProfiler->Start('callModule', $sModuleName . '->' . $sMethod . '()');
     $sModuleName = strtolower($sModuleName);
     $aResultHook = array();
     if (!in_array($sModuleName, array('plugin', 'hook'))) {
         $aResultHook = $this->_CallModule('Hook_Run', array('module_' . $sModuleName . '_' . strtolower($sMethod) . '_before', &$aArgs));
     }
     if (array_key_exists('delegate_result', $aResultHook)) {
         $result = $aResultHook['delegate_result'];
     } else {
         $aArgsRef = array();
         foreach ($aArgs as $key => $v) {
             $aArgsRef[] =& $aArgs[$key];
         }
         $result = call_user_func_array(array($oModule, $sMethod), $aArgsRef);
     }
     if (!in_array($sModuleName, array('plugin', 'hook'))) {
         $this->Hook_Run('module_' . $sModuleName . '_' . strtolower($sMethod) . '_after', array('result' => &$result, 'params' => $aArgs));
     }
     $oProfiler->Stop($iTimeId);
     return $result;
 }
コード例 #9
0
 function profileIn($functionname)
 {
     parent::profileIn($functionname);
     $this->trace .= "         " . sprintf("%6.1f", $this->memoryDiff()) . str_repeat(" ", count($this->mWorkStack)) . " > " . $functionname . "\n";
 }