function G($start = '', $end = '', $dec = 3) { if (empty($_GET['need_stat'])) { //return false; } static $_info = array(); if (is_float($end)) { $info[$start] = $end; } elseif (!empty($end)) { if (!isset($_info[$end])) { $_info[$end] = my_microtime_float($dec); } return number_format($_info[$end] - $_info[$start], $dec); } elseif (!empty($start)) { $_info[$start] = my_microtime_float($dec); } else { $temp = array(); $findFirst = true; foreach ($_info as $key => $value) { if ($findFirst) { $baseTime = $value; $lastTime = 0; $findFirst = false; } $currTime = bcsub($value, $baseTime, 3); $currCostTime = bcsub($currTime, $lastTime, 3); $lastTime = $currTime; $temp[$key] = $currTime . ' [' . $currCostTime . ']'; } return $temp; } }
function loginfo($stime, $sql) { $querytime = my_microtime_float() - $stime; if ($querytime > 1000) { $GLOBALS['LOGGER']->info("exectime: " . $querytime . " " . $sql); } }