]> git.mjollnir.org Git - s9y.git/commitdiff
Allow for some more benchmarkiness
authorgarvinhicking <garvinhicking>
Tue, 27 Feb 2007 12:15:00 +0000 (12:15 +0000)
committergarvinhicking <garvinhicking>
Tue, 27 Feb 2007 12:15:00 +0000 (12:15 +0000)
include/db/mysql.inc.php

index 56c474c1d0bb707901edbb92292965ad2005cf03..512b2dfe2db9bc9e3e66f7566c558a6b0dacc095 100644 (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']) != '') {