From: Domas Mituzas Date: Sun, 28 May 2006 21:25:03 +0000 (+0000) Subject: microtime(true) instead of slow php4 hacks X-Git-Tag: 1.31.0-rc.0~56988 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=9aa7ac0d2c8656daf8d328fe8ef1ef02827da641;p=lhc%2Fweb%2Fwiklou.git microtime(true) instead of slow php4 hacks --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index cbd58214de..0a148e127a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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); } /** diff --git a/includes/Profiling.php b/includes/Profiling.php index 42d0a6eb54..edecc4f32f 100644 --- a/includes/Profiling.php +++ b/includes/Profiling.php @@ -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]; diff --git a/index.php b/index.php index ba9799fbda..f18fa8a6ed 100644 --- 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' ) ) { diff --git a/maintenance/commandLine.inc b/maintenance/commandLine.inc index 416a8877d8..2bb5389e82 100644 --- a/maintenance/commandLine.inc +++ b/maintenance/commandLine.inc @@ -5,7 +5,7 @@ * @subpackage Maintenance */ -$wgRequestTime = microtime(); +$wgRequestTime = microtime(true); /** */ # Abort if called from a web server