Changeset 18990


Ignore:
Timestamp:
2010/11/06 20:27:45 (13 years ago)
Author:
uchida
Message:

execution time log.

Location:
branches/camp/camp-2_5-D
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/camp/camp-2_5-D/data/class/SC_Query.php

    r18980 r18990  
    775775     */ 
    776776    function execute(&$sth, $arrVal = array()) { 
     777        $timeStart = SC_Utils_Ex::sfMicrotimeFloat(); 
    777778        $affected =& $sth->execute($arrVal); 
     779 
     780        // 一定以上時間かかったSQLの場合、ログ出力する。 
     781        if(defined('SQL_QUERY_LOG_MODE') && SQL_QUERY_LOG_MODE == true) { 
     782            $timeEnd = SC_Utils_Ex::sfMicrotimeFloat();; 
     783            $timeExecTime = $timeEnd - $timeStart; 
     784            if(defined('SQL_QUERY_LOG_MIN_EXEC_TIME') && $timeExecTime >= (float)SQL_QUERY_LOG_MIN_EXEC_TIME) { 
     785                //$logMsg = sprintf("SQL_LOG [%.2fsec]\n%s", $timeExecTime, $this->getLastQuery(false)); 
     786                $logMsg = sprintf("SQL_LOG [%.2fsec]\n%s", $timeExecTime, $sth->query); 
     787                GC_Utils_Ex::gfPrintLog($logMsg); 
     788            } 
     789        } 
     790 
    778791        if (PEAR::isError($affected)) { 
    779792            $sql = isset($sth->query) ? $sth->query : ''; 
  • branches/camp/camp-2_5-D/data/class/pages/LC_Page.php

    r18701 r18990  
    8282     */ 
    8383    function init() { 
     84        // 開始時刻を設定する。 
     85        $this->timeStart = SC_Utils_Ex::sfMicrotimeFloat(); 
     86 
    8487        $this->tpl_authority = $_SESSION['authority']; 
    8588        // XXX すべてのページで宣言するべき 
     
    100103     * @return void 
    101104     */ 
    102     function destroy() {} 
     105    function destroy() { 
     106        // 一定時間以上かかったページの場合、ログ出力する。 
     107        if(defined('PAGE_DISPLAY_TIME_LOG_MODE') && PAGE_DISPLAY_TIME_LOG_MODE == true) { 
     108            $timeEnd = SC_Utils_Ex::sfMicrotimeFloat();; 
     109            $timeExecTime = $timeEnd - $this->timeStart; 
     110            if(defined('PAGE_DISPLAY_TIME_LOG_MIN_EXEC_TIME') && $timeExecTime >= (float)PAGE_DISPLAY_TIME_LOG_MIN_EXEC_TIME) { 
     111                $logMsg = sprintf("PAGE_DISPLAY_TIME_LOG [%.2fsec]", $timeExecTime); 
     112                GC_Utils_Ex::gfPrintLog($logMsg); 
     113            } 
     114        } 
     115 
     116    } 
    103117 
    104118    /** 
  • branches/camp/camp-2_5-D/html/install/sql/insert_data.sql

    r18882 r18990  
    10801080INSERT INTO mtb_constants (id, name, rank, remarks) VALUES ('PRODUCT_TYPE_NORMAL', '1', 900, '通常商品'); 
    10811081INSERT INTO mtb_constants (id, name, rank, remarks) VALUES ('PRODUCT_TYPE_DOWNLOAD', '2', 901, 'ダウンロード商品'); 
     1082INSERT INTO mtb_constants (id, name, rank, remarks) VALUES ('SQL_QUERY_LOG_MODE', '1', 902, 'SQLログを取得するフラグ(1:表示, 0:非表示)'); 
     1083INSERT INTO mtb_constants (id, name, rank, remarks) VALUES ('SQL_QUERY_LOG_MIN_EXEC_TIME', '2', 903, 'SQLログを取得する時間設定(設定値以上かかった場合に取得)'); 
     1084INSERT INTO mtb_constants (id, name, rank, remarks) VALUES ('PAGE_DISPLAY_TIME_LOG_MODE', '1', 904, 'ページ表示時間のログを取得するフラグ(1:表示, 0:非表示)'); 
     1085INSERT INTO mtb_constants (id, name, rank, remarks) VALUES ('PAGE_DISPLAY_TIME_LOG_MIN_EXEC_TIME', '2', 905, 'ページ表示時間のログを取得する時間設定(設定値以上かかった場合に取得)'); 
     1086 
Note: See TracChangeset for help on using the changeset viewer.