function debuginfo() { global $_G; if (getglobal('setting/debug')) { $db =& DB::object(); $_G['debuginfo'] = array('time' => number_format(dmicrotime() - $_G['starttime'], 6), 'queries' => $db->querynum, 'memory' => ucwords($_G['memory'])); return TRUE; } else { return FALSE; } }
function query($sql, $type = '') { if (defined('DISCUZ_DEBUG') && DISCUZ_DEBUG) { $starttime = dmicrotime(); } $func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query'; if (!($query = $func($sql, $this->curlink))) { if (in_array($this->errno(), array(2006, 2013)) && substr($type, 0, 5) != 'RETRY') { $this->connect(); return $this->query($sql, 'RETRY' . $type); } if ($type != 'SILENT' && substr($type, 5) != 'SILENT') { $this->halt('query_error', $sql); } } if (defined('DISCUZ_DEBUG') && DISCUZ_DEBUG) { $this->sqldebug[] = array($sql, number_format(dmicrotime() - $starttime, 6), debug_backtrace()); } $this->querynum++; return $query; }
public static function easybug() { self::$var['bug']['runsql'] = 0; if (!self::$var['ajax'] && function_exists('xdebug_time_index')) { self::$var['bug']['runsec'] = function_exists('xdebug_time_index') ? number_format(xdebug_time_index(), 6) : number_format(dmicrotime() - RUNFIRSTTIME, 6); $html = '<p>' . self::$var['bug']['runsec'] . 's, runsize: ' . xdebug_memory_usage() . 'Kb, runavgsize: ' . xdebug_peak_memory_usage() . 'Kb, runsql:' . var_export(self::$var['bug']['runsql'], true) . '</p>'; echo $html; } else { self::$var['bug']['runsec'] = number_format(dmicrotime() - self::$var['starttime'], 6); self::$var['bug']['runmemory'] = intval(return_bytes(memory_get_usage() / (1024 * 1024) . 'k')); self::$var['bug']['runsql'] = Factory_Db::countSqlNum(); } }