]> git.mjollnir.org Git - s9y.git/commitdiff
Some optimizations + benchmarks
authorgarvinhicking <garvinhicking>
Tue, 18 Apr 2006 08:24:34 +0000 (08:24 +0000)
committergarvinhicking <garvinhicking>
Tue, 18 Apr 2006 08:24:34 +0000 (08:24 +0000)
include/db/mysql.inc.php
include/functions_config.inc.php

index 27ad8b636b035a4d9e0ba3d8e0ea6652b1280a61..db9027fb889a87a02721ea4b02b51705be53ebde 100644 (file)
@@ -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<br />\n";
+    }
+
 
     if (!$expectError && mysql_error($serendipity['dbConn']) != '') {
         $msg = '<pre>' . $sql . '</pre> / ' . mysql_error($serendipity['dbConn']);
index b42deeba131257450733faba67795f9179027208..438f8b9d7205a13f447c11ef929f394fa6474ecd 100644 (file)
@@ -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;
 }
 
 /**