From: Alexander Ebert Date: Sun, 2 Jun 2013 19:55:29 +0000 (+0200) Subject: Added performance logging for initial SQL creation X-Git-Tag: 2.0.0_Beta_3~26^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=09700910ca116537097acbe62108f87718105323;p=GitHub%2FWoltLab%2FWCF.git Added performance logging for initial SQL creation --- diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index 8ee2ef5390..e6045e0eb6 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -727,6 +727,12 @@ class WCFSetup extends WCF { // installation number value 'n' (WCF_N) must be reflected in the executed sql queries $sql = StringUtil::replace('wcf1_', 'wcf'.WCF_N.'_', $sql); + $GLOBALS['__db'] = array( + 'parse' => 0, + 'modify' => 0, + 'insert' => 0 + ); + // execute sql queries $parser = new SQLParser($sql); $parser->execute(); @@ -735,6 +741,7 @@ class WCFSetup extends WCF { preg_match_all("~CREATE\s+TABLE\s+(\w+)~i", $sql, $matches); if (!empty($matches[1])) { + $s2 = microtime(true); $sql = "INSERT INTO wcf".WCF_N."_package_installation_sql_log (sqlTable) VALUES (?)"; @@ -742,8 +749,11 @@ class WCFSetup extends WCF { foreach ($matches[1] as $tableName) { $statement->execute(array($tableName)); } + $GLOBALS['__db']['insert'] = round(microtime(true) - $s2, 3); } + file_put_contents(WCF_DIR.'__sqlPerformance.log', print_r($GLOBALS['__db'])); + /* * Manually install PIPPackageInstallationPlugin since install.sql content is not escaped resulting * in different behaviour in MySQL and MSSQL. You SHOULD NOT move this into install.sql! diff --git a/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php b/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php index c2d469f38b..48223d7949 100644 --- a/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php +++ b/wcfsetup/install/files/lib/system/database/util/SQLParser.class.php @@ -46,7 +46,11 @@ class SQLParser { if (preg_match('~^(ALTER\s+TABLE|CREATE\s+INDEX|CREATE\s+TABLE|DROP\s+INDEX|DROP\s+TABLE|INSERT|UPDATE|DELETE)~i', $query, $match)) { $statement = strtoupper(preg_replace('~\s+~', ' ', $match[0])); + $GLOBALS['__db']['parse']++; + + $s = microtime(true); $this->executeStatement($statement, $query); + $GLOBALS['__db']['modify'] += round(microtime(true) - $s, 3); } } }