* Fix Profiler::getUserTime() to return a float and not string with space separated...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 15 Jan 2012 11:42:36 +0000 (11:42 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 15 Jan 2012 11:42:36 +0000 (11:42 +0000)
* Same when adding fake items in the stack after a profiling error
* Removed useless ProfilerSimple::getTime()

includes/profiler/Profiler.php
includes/profiler/ProfilerSimple.php

index bb6ab13..6deac89 100644 (file)
@@ -150,12 +150,12 @@ class Profiler {
                                if( $functionname == 'close' ){
                                        $message = "Profile section ended by close(): {$bit[0]}";
                                        $this->debug( "$message\n" );
-                                       $this->mStack[] = array( $message, 0, '0 0', 0, '0 0', 0 );
+                                       $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 );
                                }
                                elseif( $bit[0] != $functionname ){
                                        $message = "Profiling error: in({$bit[0]}), out($functionname)";
                                        $this->debug( "$message\n" );
-                                       $this->mStack[] = array( $message, 0, '0 0', 0, '0 0', 0 );
+                                       $this->mStack[] = array( $message, 0, 0.0, 0, 0.0, 0 );
                                }
                        //}
                        $bit[] = $time;
@@ -265,13 +265,13 @@ class Profiler {
                if ( $this->mTimeMetric === 'user' ) {
                        return $this->getUserTime();
                } else {
-                       return microtime(true);
+                       return microtime( true );
                }
        }
 
        function getUserTime() {
                $ru = getrusage();
-               return $ru['ru_utime.tv_sec'].' '.$ru['ru_utime.tv_usec'] / 1e6;
+               return $ru['ru_utime.tv_sec'] + $ru['ru_utime.tv_usec'] / 1e6;
        }
 
        protected function collateData() {
index bbdbec8..055a0ea 100644 (file)
@@ -115,13 +115,4 @@ class ProfilerSimple extends Profiler {
                        return 0;
                }
        }
-
-       /* If argument is passed, it assumes that it is dual-format time string, returns proper float time value */
-       function getTime($time=null) {
-               if ($time==null) {
-                       return microtime(true);
-               }
-               list($a,$b)=explode(" ",$time);
-               return (float)($a+$b);
-       }
 }