Merge "Cleanup for ApiImageRotate"
[lhc/web/wiklou.git] / includes / profiler / Profiler.php
index b30b031..5ecdc4f 100644 (file)
@@ -28,7 +28,7 @@
 
 /**
  * Begin profiling of a function
- * @param $functionname String: name of the function we will profile
+ * @param string $functionname name of the function we will profile
  */
 function wfProfileIn( $functionname ) {
        global $wgProfiler;
@@ -39,7 +39,7 @@ function wfProfileIn( $functionname ) {
 
 /**
  * Stop profiling of a function
- * @param $functionname String: name of the function we have profiled
+ * @param string $functionname name of the function we have profiled
  */
 function wfProfileOut( $functionname = 'missing' ) {
        global $wgProfiler;
@@ -178,10 +178,10 @@ class Profiler {
                        $this->debug( str_repeat( ' ', count( $this->mWorkStack ) - 1 ) . 'Exiting ' . $functionname . "\n" );
                }
 
-               $bit = array_pop($this->mWorkStack);
+               $bit = array_pop( $this->mWorkStack );
 
-               if (!$bit) {
-                       $this->debug("Profiling error, !\$bit: $functionname\n");
+               if ( !$bit ) {
+                       $this->debug( "Profiling error, !\$bit: $functionname\n" );
                } else {
                        //if( $wgDebugProfiling ) {
                                if( $functionname == 'close' ) {
@@ -250,7 +250,7 @@ class Profiler {
        /**
         * Recursive function the format the current profiling array into a tree
         *
-        * @param $stack array profiling array
+        * @param array $stack profiling array
         * @return array
         */
        function remapCallTree( $stack ) {
@@ -293,9 +293,9 @@ class Profiler {
         * @return string
         */
        function getCallTreeLine( $entry ) {
-               list( $fname, $level, $start, /* $x */, $end = $entry;
+               list( $fname, $level, $start, /* $x */, $end ) = $entry;
                $delta = $end - $start;
-               $space = str_repeat(' ', $level);
+               $space = str_repeat( ' ', $level );
                # The ugly double sprintf is to work around a PHP bug,
                # which has been fixed in recent releases.
                return sprintf( "%10s %s %s\n", trim( sprintf( "%7.3f", $delta * 1000.0 ) ), $space, $fname );
@@ -305,7 +305,7 @@ class Profiler {
         * Get the initial time of the request, based either on $wgRequestTime or
         * $wgRUstart. Will return null if not able to find data.
         *
-        * @param $metric string|false: metric to use, with the following possibilities:
+        * @param string|false $metric metric to use, with the following possibilities:
         *   - user: User CPU time (without system calls)
         *   - cpu: Total CPU time (user and system calls)
         *   - wall (or any other string): elapsed time
@@ -338,7 +338,7 @@ class Profiler {
         * Get the initial time of the request, based either on $wgRequestTime or
         * $wgRUstart. Will return null if not able to find data.
         *
-        * @param $metric string|false: metric to use, with the following possibilities:
+        * @param string|false $metric metric to use, with the following possibilities:
         *   - user: User CPU time (without system calls)
         *   - cpu: Total CPU time (user and system calls)
         *   - wall (or any other string): elapsed time
@@ -386,7 +386,7 @@ class Profiler {
                $this->mMemory = array();
 
                # Estimate profiling overhead
-               $profileCount = count($this->mStack);
+               $profileCount = count( $this->mStack );
                self::calculateOverhead( $profileCount );
 
                # First, subtract the overhead!
@@ -441,8 +441,8 @@ class Profiler {
                        $this->mCollated[$fname] += $elapsed;
                        $this->mCalls[$fname]++;
                        $this->mMemory[$fname] += $memory;
-                       $this->mMin[$fname] = min($this->mMin[$fname], $elapsed);
-                       $this->mMax[$fname] = max($this->mMax[$fname], $elapsed);
+                       $this->mMin[$fname] = min( $this->mMin[$fname], $elapsed );
+                       $this->mMax[$fname] = max( $this->mMax[$fname], $elapsed );
                        $this->mOverhead[$fname] += $subcalls;
                }
 
@@ -460,7 +460,7 @@ class Profiler {
 
                $width = 140;
                $nameWidth = $width - 65;
-               $format =      "%-{$nameWidth}s %6d %13.3f %13.3f %13.3f%% %9d  (%13.3f -%13.3f) [%d]\n";
+               $format = "%-{$nameWidth}s %6d %13.3f %13.3f %13.3f%% %9d  (%13.3f -%13.3f) [%d]\n";
                $titleFormat = "%-{$nameWidth}s %6s %13s %13s %13s %9s\n";
                $prof = "\nProfiling data\n";
                $prof .= sprintf( $titleFormat, 'Name', 'Calls', 'Total', 'Each', '%', 'Mem' );
@@ -499,10 +499,10 @@ class Profiler {
         * @return Integer
         * @private
         */
-       function calltreeCount($stack, $start) {
+       function calltreeCount( $stack, $start ) {
                $level = $stack[$start][1];
                $count = 0;
-               for ($i = $start -1; $i >= 0 && $stack[$i][1] > $level; $i --) {
+               for ( $i = $start -1; $i >= 0 && $stack[$i][1] > $level; $i-- ) {
                        $count ++;
                }
                return $count;
@@ -557,9 +557,9 @@ class Profiler {
 
                                $rc = $dbw->affectedRows();
                                if ( $rc == 0 ) {
-                                       $dbw->insert('profiling', array ('pf_name' => $name, 'pf_count' => $eventCount,
+                                       $dbw->insert( 'profiling', array ( 'pf_name' => $name, 'pf_count' => $eventCount,
                                                'pf_time' => $timeSum, 'pf_memory' => $memorySum, 'pf_server' => $pfhost ),
-                                               __METHOD__, array ('IGNORE'));
+                                               __METHOD__, array ( 'IGNORE' ) );
                                }
                                // When we upgrade to mysql 4.1, the insert+update
                                // can be merged into just a insert with this construct added:
@@ -582,7 +582,7 @@ class Profiler {
        /**
         * Add an entry in the debug log file
         *
-        * @param $s String to output
+        * @param string $s to output
         */
        function debug( $s ) {
                if( defined( 'MW_COMPILED' ) || function_exists( 'wfDebug' ) ) {