Allow for some more benchmarkiness

This commit is contained in:
Garvin Hicking 2007-02-27 12:15:00 +00:00
parent cb416979a3
commit b4bfc40ae1

View File

@ -85,7 +85,14 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re
}
if ($benchmark) {
$end = microtime_float();
echo "[bench: " . ($end-$start) . "s] $sql<br />\n";
mysql_query("INSERT INTO BLOGLOG (request, timestamp, sql, exec_time, ip) VALUES ('" . serendipity_db_escape_string($_SERVER['REQUEST_URI']) . "', NOW(), '" . serendipity_db_escape_string($sql) . "', '" . (number_format($end-$start, 10)) . "', '" . serendipity_db_escape_string($_SERVER['REMOTE_ADDR']) . "')");
$psql = $sql;
$psql = preg_replace('@[0-9]{10}@', 'TIMESTAMP', $psql);
mysql_query("UPDATE BLOGLOG_TOTAL SET counter = counter + 1 WHERE sql = '" . serendipity_db_escape_string($psql) . "'");
if (mysql_affected_rows() < 1) {
mysql_query("INSERT INTO BLOGLOG_TOTAL (sql, counter) VALUES ('" . serendipity_db_escape_string($psql) . "', 1)");
}
}
if (!$expectError && mysql_error($serendipity['dbConn']) != '') {