microtime(true) instead of slow php4 hacks
authorDomas Mituzas <midom@users.mediawiki.org>
Sun, 28 May 2006 21:25:03 +0000 (21:25 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Sun, 28 May 2006 21:25:03 +0000 (21:25 +0000)
includes/GlobalFunctions.php
includes/Profiling.php
index.php
maintenance/commandLine.inc

index cbd5821..0a148e1 100644 (file)
@@ -916,8 +916,7 @@ function wfQuotedPrintable( $string, $charset = '' ) {
  * @return float
  */
 function wfTime() {
-       $st = explode( ' ', microtime() );
-       return (float)$st[0] + (float)$st[1];
+       return microtime(true);
 }
 
 /**
index 42d0a6e..edecc4f 100644 (file)
@@ -51,7 +51,7 @@ class Profiler {
                global $wgRequestTime;
                if ( !empty( $wgRequestTime ) ) {
                        $this->mWorkStack[] = array( '-total', 0, $wgRequestTime, 0 );
-                       $this->mStack[] = array( '-setup', 1, $wgRequestTime, 0, microtime(), 0 );
+                       $this->mStack[] = array( '-setup', 1, $wgRequestTime, 0, microtime(true), 0 );
                } else {
                        $this->profileIn( '-total' );
                }
@@ -163,7 +163,7 @@ class Profiler {
 
        function getCallTreeLine($entry) {
                list ($fname, $level, $start, $x, $end) = $entry;
-               $delta = $this->microDelta($start, $end);
+               $delta = $end - $start;
                $space = str_repeat(' ', $level);
 
                # The ugly double sprintf is to work around a PHP bug,
@@ -173,18 +173,8 @@ class Profiler {
                        $space, $fname );
        }
 
-       function micro2Float( $micro ) {
-               list( $whole, $fractional ) = explode( ' ', $micro );
-               return (float)$whole + (float)$fractional;
-       }
-
-       function microDelta( $start, $end ) {
-               return $this->micro2Float( $end ) -
-                      $this->micro2Float( $start );
-       }
-
        function getTime() {
-               return microtime();
+               return microtime(true);
                #return $this->getUserTime();
        }
 
@@ -217,10 +207,8 @@ class Profiler {
                foreach ($this->mStack as $entry) {
                        $fname = $entry[0];
                        $thislevel = $entry[1];
-                       $start = explode(' ', $entry[2]);
-                       $start = (float) $start[0] + (float) $start[1];
-                       $end = explode(' ', $entry[4]);
-                       $end = (float) $end[0] + (float) $end[1];
+                       $start = $entry[2];
+                       $end = $entry[4];
                        $elapsed = $end - $start;
                        $memory = $entry[5] - $entry[3];
 
@@ -240,10 +228,8 @@ class Profiler {
                foreach ($this->mStack as $index => $entry) {
                        $fname = $entry[0];
                        $thislevel = $entry[1];
-                       $start = explode(' ', $entry[2]);
-                       $start = (float) $start[0] + (float) $start[1];
-                       $end = explode(' ', $entry[4]);
-                       $end = (float) $end[0] + (float) $end[1];
+                       $start = $entry[2];
+                       $end = $entry[4];
                        $elapsed = $end - $start;
 
                        $memory = $entry[5] - $entry[3];
index ba9799f..f18fa8a 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
  * Main wiki script; see docs/design.txt
  * @package MediaWiki
  */
-$wgRequestTime = microtime();
+$wgRequestTime = microtime(true);
 
 # getrusage() does not exist on the Microsoft Windows platforms, catching this
 if ( function_exists ( 'getrusage' ) ) {
index 416a887..2bb5389 100644 (file)
@@ -5,7 +5,7 @@
  * @subpackage Maintenance
  */
 
-$wgRequestTime = microtime();
+$wgRequestTime = microtime(true);
 
 /** */
 # Abort if called from a web server