From b97de7fe153dd83eaeeeb8fd7a2b24014c49db8e Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Tue, 27 Feb 2007 12:15:00 +0000 Subject: [PATCH] Allow for some more benchmarkiness --- include/db/mysql.inc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/db/mysql.inc.php b/include/db/mysql.inc.php index 56c474c..512b2df 100644 --- a/include/db/mysql.inc.php +++ b/include/db/mysql.inc.php @@ -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
\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']) != '') { -- 2.39.5