Instrument diff timing
authorMax Semenik <maxsem.wiki@gmail.com>
Fri, 4 Mar 2016 22:41:50 +0000 (14:41 -0800)
committerMax Semenik <maxsem.wiki@gmail.com>
Fri, 4 Mar 2016 23:06:48 +0000 (15:06 -0800)
Bug: T128697
Change-Id: I748286abac025092abc33b3b7b8a0d3dabafdd25

includes/diff/DifferenceEngine.php

index 1fa1970..1cf3918 100644 (file)
@@ -842,6 +842,24 @@ class DifferenceEngine extends ContextSource {
         * @return bool|string
         */
        public function generateTextDiffBody( $otext, $ntext ) {
+               $time = microtime( true );
+
+               $result = $this->textDiff( $otext, $ntext );
+
+               $time = microtime( true ) - $time;
+               $this->getStats()->timing( 'diff_time', $time );
+
+               return $result;
+       }
+
+       /**
+        * Generates diff, to be wrapped internally in a logging/instrumentation
+        *
+        * @param string $otext Old text, must be already segmented
+        * @param string $ntext New text, must be already segmented
+        * @return bool|string
+        */
+       protected function textDiff( $otext, $ntext ) {
                global $wgExternalDiffEngine, $wgContLang;
 
                $otext = str_replace( "\r\n", "\n", $otext );