Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/application.php
Show First 20 Lines • Show All 1233 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function _storeStatistics() | protected function _storeStatistics() | ||||
{ | { | ||||
global $start; | global $start; | ||||
$this->Conn->noDebuggingState = true; | |||||
$script_time = microtime(true) - $start; | $script_time = microtime(true) - $start; | ||||
$query_statistics = $this->Conn->getQueryStatistics(); // time & count | $query_statistics = $this->Conn->getQueryStatistics(); // time & count | ||||
$sql = 'SELECT * | $sql = 'SELECT * | ||||
FROM ' . TABLE_PREFIX . 'StatisticsCapture | FROM ' . TABLE_PREFIX . 'StatisticsCapture | ||||
WHERE TemplateName = ' . $this->Conn->qstr($this->GetVar('t')); | WHERE TemplateName = ' . $this->Conn->qstr($this->GetVar('t')); | ||||
$data = $this->Conn->GetRow($sql); | $data = $this->Conn->GetRow($sql); | ||||
Show All 12 Lines | |||||
$data['ScriptTimeMin'] = $data['ScriptTimeAvg'] = $data['ScriptTimeMax'] = $script_time; | $data['ScriptTimeMin'] = $data['ScriptTimeAvg'] = $data['ScriptTimeMax'] = $script_time; | ||||
$data['SqlTimeMin'] = $data['SqlTimeAvg'] = $data['SqlTimeMax'] = $query_statistics['time']; | $data['SqlTimeMin'] = $data['SqlTimeAvg'] = $data['SqlTimeMax'] = $query_statistics['time']; | ||||
$data['SqlCountMin'] = $data['SqlCountAvg'] = $data['SqlCountMax'] = $query_statistics['count']; | $data['SqlCountMin'] = $data['SqlCountAvg'] = $data['SqlCountMax'] = $query_statistics['count']; | ||||
$data['TemplateName'] = $this->GetVar('t'); | $data['TemplateName'] = $this->GetVar('t'); | ||||
$data['Hits'] = 1; | $data['Hits'] = 1; | ||||
$data['LastHit'] = adodb_mktime(); | $data['LastHit'] = adodb_mktime(); | ||||
$this->Conn->doInsert($data, TABLE_PREFIX . 'StatisticsCapture'); | $this->Conn->doInsert($data, TABLE_PREFIX . 'StatisticsCapture'); | ||||
} | } | ||||
$this->Conn->noDebuggingState = false; | |||||
} | } | ||||
/** | /** | ||||
* Calculates average time for statistics | * Calculates average time for statistics | ||||
* | * | ||||
* @param Array $data | * @param Array $data | ||||
* @param string $field_prefix | * @param string $field_prefix | ||||
* @param float $current_value | * @param float $current_value | ||||
Show All 18 Lines | |||||
* | * | ||||
* @param string $slow_sql | * @param string $slow_sql | ||||
* @param int $time | * @param int $time | ||||
* @return void | * @return void | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function logSlowQuery($slow_sql, $time) | public function logSlowQuery($slow_sql, $time) | ||||
{ | { | ||||
$this->Conn->noDebuggingState = true; | |||||
$query_crc = kUtil::crc32($slow_sql); | $query_crc = kUtil::crc32($slow_sql); | ||||
$sql = 'SELECT * | $sql = 'SELECT * | ||||
FROM ' . TABLE_PREFIX . 'SlowSqlCapture | FROM ' . TABLE_PREFIX . 'SlowSqlCapture | ||||
WHERE QueryCrc = ' . $query_crc; | WHERE QueryCrc = ' . $query_crc; | ||||
$data = $this->Conn->Query($sql, null, true); | $data = $this->Conn->Query($sql); | ||||
if ( $data ) { | if ( $data ) { | ||||
$data = array_shift($data); // Because "Query" method (supports $no_debug) is used instead of "GetRow". | $data = array_shift($data); // Because "Query" method (supports $no_debug) is used instead of "GetRow". | ||||
$this->_updateAverageStatistics($data, 'Time', $time); | $this->_updateAverageStatistics($data, 'Time', $time); | ||||
$template_names = explode(',', $data['TemplateNames']); | $template_names = explode(',', $data['TemplateNames']); | ||||
array_push($template_names, $this->GetVar('t')); | array_push($template_names, $this->GetVar('t')); | ||||
$data['TemplateNames'] = implode(',', array_unique($template_names)); | $data['TemplateNames'] = implode(',', array_unique($template_names)); | ||||
Show All 9 Lines | |||||
$data['SqlQuery'] = $slow_sql; | $data['SqlQuery'] = $slow_sql; | ||||
$data['QueryCrc'] = $query_crc; | $data['QueryCrc'] = $query_crc; | ||||
$data['TemplateNames'] = $this->GetVar('t'); | $data['TemplateNames'] = $this->GetVar('t'); | ||||
$data['Hits'] = 1; | $data['Hits'] = 1; | ||||
$data['LastHit'] = adodb_mktime(); | $data['LastHit'] = adodb_mktime(); | ||||
$this->Conn->doInsert($data, TABLE_PREFIX . 'SlowSqlCapture'); | $this->Conn->doInsert($data, TABLE_PREFIX . 'SlowSqlCapture'); | ||||
} | } | ||||
$this->Conn->noDebuggingState = false; | |||||
} | } | ||||
/** | /** | ||||
* Checks if output compression options is available | * Checks if output compression options is available | ||||
* | * | ||||
* @return bool | * @return bool | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1799 Lines • Show Last 20 Lines |