From 499e7fc43087ac2d6f28e70e8dae3f2224f6d902 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Tue, 18 Apr 2006 08:24:34 +0000 Subject: [PATCH] Some optimizations + benchmarks --- include/db/mysql.inc.php | 9 +++++++++ include/functions_config.inc.php | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/include/db/mysql.inc.php b/include/db/mysql.inc.php index 27ad8b6..db9027f 100644 --- a/include/db/mysql.inc.php +++ b/include/db/mysql.inc.php @@ -67,6 +67,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re 'true' => true, 'false' => false ); + static $benchmark = false; // highlight_string(var_export($sql, 1)); @@ -74,11 +75,19 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re return false; } + if ($benchmark) { + $start = microtime_float(); + } if ($expectError) { $c = @mysql_query($sql, $serendipity['dbConn']); } else { $c = mysql_query($sql, $serendipity['dbConn']); } + if ($benchmark) { + $end = microtime_float(); + echo "[bench: " . ($end-$start) . "s] $sql
\n"; + } + if (!$expectError && mysql_error($serendipity['dbConn']) != '') { $msg = '
' . $sql . '
/ ' . mysql_error($serendipity['dbConn']); diff --git a/include/functions_config.inc.php b/include/functions_config.inc.php index b42deeb..438f8b9 100644 --- a/include/functions_config.inc.php +++ b/include/functions_config.inc.php @@ -284,6 +284,11 @@ function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath') { */ function serendipity_load_configuration($author = null) { global $serendipity; + static $config_loaded = array(); + + if (isset($config_loaded[$author])) { + return true; + } if (!empty($author)) { // Replace default configuration directives with user-relevant data @@ -303,6 +308,7 @@ function serendipity_load_configuration($author = null) { $serendipity[$row['name']] = serendipity_get_bool($row['value']); } } + $config_loaded[$author] = true; } /** -- 2.39.5