r14441 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14440‎ | r14441 | r14442 >
Date:21:25, 28 May 2006
Author:midom
Status:old
Tags:
Comment:
microtime(true) instead of slow php4 hacks
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Profiling.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)
  • /trunk/phase3/maintenance/commandLine.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/commandLine.inc
@@ -5,7 +5,7 @@
66 * @subpackage Maintenance
77 */
88
9 -$wgRequestTime = microtime();
 9+$wgRequestTime = microtime(true);
1010
1111 /** */
1212 # Abort if called from a web server
Index: trunk/phase3/index.php
@@ -3,7 +3,7 @@
44 * Main wiki script; see docs/design.txt
55 * @package MediaWiki
66 */
7 -$wgRequestTime = microtime();
 7+$wgRequestTime = microtime(true);
88
99 # getrusage() does not exist on the Microsoft Windows platforms, catching this
1010 if ( function_exists ( 'getrusage' ) ) {
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -916,8 +916,7 @@
917917 * @return float
918918 */
919919 function wfTime() {
920 - $st = explode( ' ', microtime() );
921 - return (float)$st[0] + (float)$st[1];
 920+ return microtime(true);
922921 }
923922
924923 /**
Index: trunk/phase3/includes/Profiling.php
@@ -51,7 +51,7 @@
5252 global $wgRequestTime;
5353 if ( !empty( $wgRequestTime ) ) {
5454 $this->mWorkStack[] = array( '-total', 0, $wgRequestTime, 0 );
55 - $this->mStack[] = array( '-setup', 1, $wgRequestTime, 0, microtime(), 0 );
 55+ $this->mStack[] = array( '-setup', 1, $wgRequestTime, 0, microtime(true), 0 );
5656 } else {
5757 $this->profileIn( '-total' );
5858 }
@@ -163,7 +163,7 @@
164164
165165 function getCallTreeLine($entry) {
166166 list ($fname, $level, $start, $x, $end) = $entry;
167 - $delta = $this->microDelta($start, $end);
 167+ $delta = $end - $start;
168168 $space = str_repeat(' ', $level);
169169
170170 # The ugly double sprintf is to work around a PHP bug,
@@ -173,18 +173,8 @@
174174 $space, $fname );
175175 }
176176
177 - function micro2Float( $micro ) {
178 - list( $whole, $fractional ) = explode( ' ', $micro );
179 - return (float)$whole + (float)$fractional;
180 - }
181 -
182 - function microDelta( $start, $end ) {
183 - return $this->micro2Float( $end ) -
184 - $this->micro2Float( $start );
185 - }
186 -
187177 function getTime() {
188 - return microtime();
 178+ return microtime(true);
189179 #return $this->getUserTime();
190180 }
191181
@@ -217,10 +207,8 @@
218208 foreach ($this->mStack as $entry) {
219209 $fname = $entry[0];
220210 $thislevel = $entry[1];
221 - $start = explode(' ', $entry[2]);
222 - $start = (float) $start[0] + (float) $start[1];
223 - $end = explode(' ', $entry[4]);
224 - $end = (float) $end[0] + (float) $end[1];
 211+ $start = $entry[2];
 212+ $end = $entry[4];
225213 $elapsed = $end - $start;
226214 $memory = $entry[5] - $entry[3];
227215
@@ -240,10 +228,8 @@
241229 foreach ($this->mStack as $index => $entry) {
242230 $fname = $entry[0];
243231 $thislevel = $entry[1];
244 - $start = explode(' ', $entry[2]);
245 - $start = (float) $start[0] + (float) $start[1];
246 - $end = explode(' ', $entry[4]);
247 - $end = (float) $end[0] + (float) $end[1];
 232+ $start = $entry[2];
 233+ $end = $entry[4];
248234 $elapsed = $end - $start;
249235
250236 $memory = $entry[5] - $entry[3];

Status & tagging log