summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_dbi.class12
1 files changed, 6 insertions, 6 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 9ccfd48..368045b 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -431,7 +431,7 @@ function clear($pp = true)
function query($query, $p = array())
{
$p += $this->_p;
- $start = gettimeofday();
+ $start = gettimeofday(true);
if ($p['server_update'] && !preg_match('/^(EXPLAIN|SELECT|SHOW) /i', $query))
{
@@ -468,12 +468,12 @@ function query($query, $p = array())
}
- if ($GLOBALS['debug_sqllog'] || $GLOBALS['debug_sqltrace'])
+ $msec = round(1000 * (gettimeofday(true) - $start));
+ $slow = $msec >= 2000;
+ if ($GLOBALS['debug_sqllog'] || $GLOBALS['debug_sqltrace'] || $slow)
{
- $end = gettimeofday();
- $msec = round(($end['sec'] - $start['sec']) * 1000 + ($end['usec'] - $start['usec']) / 1000);
- $backtrace = EDC('sqltrace') ? it_debug::backtrace(1) : null;
- it::log('sqllog', rtrim("$msec\t$query\t$backtrace"));
+ $backtrace = (EDC('sqltrace') || $slow) ? it_debug::backtrace(1) : null;
+ it::log('sqllog', rtrim("$msec\t$query\t$backtrace" . ($slow ? "\tSLOW" : "")));
$this->_sqllog[] = array(
'time' => $msec,