Merge "DatabaseMssql: Don't duplicate body of makeList()"
[lhc/web/wiklou.git] / includes / profiler / Profiler.php
index e59b09e..4b74206 100644 (file)
@@ -48,10 +48,8 @@ abstract class Profiler {
                'udp' => 'ProfilerOutputUdp',
        );
 
-       // @codingStandardsIgnoreStart PSR2.Classes.PropertyDeclaration.Underscore
-       /** @var Profiler Do not call this outside Profiler and ProfileSection */
-       public static $__instance = null;
-       // @codingStandardsIgnoreEnd
+       /** @var Profiler */
+       private static $instance = null;
 
        /**
         * @param array $params
@@ -69,7 +67,7 @@ abstract class Profiler {
         * @return Profiler
         */
        final public static function instance() {
-               if ( self::$__instance === null ) {
+               if ( self::$instance === null ) {
                        global $wgProfiler;
                        if ( is_array( $wgProfiler ) ) {
                                $class = isset( $wgProfiler['class'] ) ? $wgProfiler['class'] : 'ProfilerStub';
@@ -77,13 +75,12 @@ abstract class Profiler {
                                if ( PHP_SAPI === 'cli' || mt_rand( 0, $factor - 1 ) != 0 ) {
                                        $class = 'ProfilerStub';
                                }
-                               /** @var Profiler */
-                               self::$__instance = new $class( $wgProfiler );
+                               self::$instance = new $class( $wgProfiler );
                        } else {
-                               self::$__instance = new ProfilerStub( array() );
+                               self::$instance = new ProfilerStub( array() );
                        }
                }
-               return self::$__instance;
+               return self::$instance;
        }
 
        /**
@@ -94,10 +91,10 @@ abstract class Profiler {
         * @since 1.25
         */
        final public static function replaceStubInstance( Profiler $profiler ) {
-               if ( self::$__instance && !( self::$__instance instanceof ProfilerStub ) ) {
+               if ( self::$instance && !( self::$instance instanceof ProfilerStub ) ) {
                        throw new MWException( 'Could not replace non-stub profiler instance.' );
                } else {
-                       self::$__instance = $profiler;
+                       self::$instance = $profiler;
                }
        }
 
@@ -119,19 +116,9 @@ abstract class Profiler {
                }
        }
 
-       /**
-        * Called by wfProfieIn()
-        *
-        * @param string $functionname
-        */
-       abstract public function profileIn( $functionname );
-
-       /**
-        * Called by wfProfieOut()
-        *
-        * @param string $functionname
-        */
-       abstract public function profileOut( $functionname );
+       // Kept BC for now, remove when possible
+       public function profileIn( $functionname ) {}
+       public function profileOut( $functionname ) {}
 
        /**
         * Mark the start of a custom profiling frame (e.g. DB queries).
@@ -242,14 +229,16 @@ abstract class Profiler {
         * This makes filtering them out easier and follows the xhprof style.
         *
         * @return array List of method entries arrays, each having:
-        *   - name    : method name
-        *   - calls   : the number of invoking calls
-        *   - real    : real time ellapsed (ms)
-        *   - %real   : percent real time
-        *   - cpu     : CPU time ellapsed (ms)
-        *   - %cpu    : percent CPU time
-        *   - memory  : memory used (bytes)
-        *   - %memory : percent memory used
+        *   - name     : method name
+        *   - calls    : the number of invoking calls
+        *   - real     : real time ellapsed (ms)
+        *   - %real    : percent real time
+        *   - cpu      : CPU time ellapsed (ms)
+        *   - %cpu     : percent CPU time
+        *   - memory   : memory used (bytes)
+        *   - %memory  : percent memory used
+        *   - min_real : min real time in a call (ms)
+        *   - max_real : max real time in a call (ms)
         * @since 1.25
         */
        abstract public function getFunctionStats();