From: Kunal Mehta Date: Sun, 21 Aug 2016 01:40:26 +0000 (-0700) Subject: debug: Don't separately calculate query runtime X-Git-Tag: 1.31.0-rc.0~5979 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22calendrier%22%2C%22type=semaine%22%29%20.%20%22?a=commitdiff_plain;h=78b167b7636fa2b86ba40de55c9578f560b4e555;p=lhc%2Fweb%2Fwiklou.git debug: Don't separately calculate query runtime It is already calculated for the transaction profiler, so re-use that. Change-Id: Ifcc43484c25e00e2409fbfb421ca2f9cecd67492 --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 0e48d919f7..186a87bb53 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -849,8 +849,6 @@ abstract class DatabaseBase implements IDatabase { wfDebugLog( 'queries', sprintf( "%s: %s", $this->mDBname, $commentedSql ) ); } - $queryId = MWDebug::query( $sql, $fname, $isMaster ); - # Avoid fatals if close() was called $this->assertOpen(); @@ -862,7 +860,7 @@ abstract class DatabaseBase implements IDatabase { $this->getTransactionProfiler()->recordQueryCompletion( $queryProf, $startTime, $isWriteQuery, $this->affectedRows() ); - MWDebug::queryTime( $queryId ); + MWDebug::query( $sql, $fname, $isMaster, $queryRuntime ); # Try reconnecting if the connection was lost if ( false === $ret && $this->wasErrorReissuable() ) { diff --git a/includes/debug/MWDebug.php b/includes/debug/MWDebug.php index d90ef8a7d1..6ce5829388 100644 --- a/includes/debug/MWDebug.php +++ b/includes/debug/MWDebug.php @@ -347,10 +347,11 @@ class MWDebug { * @param string $sql * @param string $function * @param bool $isMaster + * @param float $runTime Query run time * @return int ID number of the query to pass to queryTime or -1 if the * debugger is disabled */ - public static function query( $sql, $function, $isMaster ) { + public static function query( $sql, $function, $isMaster, $runTime ) { if ( !self::$enabled ) { return -1; } @@ -384,28 +385,12 @@ class MWDebug { 'sql' => $sql, 'function' => $function, 'master' => (bool)$isMaster, - 'time' => 0.0, - '_start' => microtime( true ), + 'time' => $runTime, ]; return count( self::$query ) - 1; } - /** - * Calculates how long a query took. - * - * @since 1.19 - * @param int $id - */ - public static function queryTime( $id ) { - if ( $id === -1 || !self::$enabled ) { - return; - } - - self::$query[$id]['time'] = microtime( true ) - self::$query[$id]['_start']; - unset( self::$query[$id]['_start'] ); - } - /** * Returns a list of files included, along with their size *