for ($i = $start - 1; $i >= 0 && $stack[$i][1] > $level; $i--) { $count++; } return $count; } /** * @static */ function logToDB($name, $timeSum, $eventCount) { $fname = 'Profiler::logToDB'; $dbw =& wfGetDB(DB_MASTER); $profiling = $dbw->tableName('profiling'); $name = substr($name, 0, 255); $encname = $dbw->strencode($name); $sql = "UPDATE {$profiling} " . "SET pf_count=pf_count+{$eventCount}, " . "pf_time=pf_time + {$timeSum} " . "WHERE pf_name='{$encname}'"; $dbw->query($sql); $rc = $dbw->affectedRows(); if ($rc == 0) { $dbw->insert('profiling', array('pf_name' => $name, 'pf_count' => $eventCount, 'pf_time' => $timeSum), $fname, array('IGNORE')); } // When we upgrade to mysql 4.1, the insert+update // can be merged into just a insert with this construct added: // "ON DUPLICATE KEY UPDATE ". // "pf_count=pf_count + VALUES(pf_count), ". // "pf_time=pf_time + VALUES(pf_time)"; } } $wgProfiler = new Profiler(); $wgProfiler->profileIn('-total');