PleaseStand has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/147018

Change subject: Remove some PHP4 microtime() compat wrappers
......................................................................

Remove some PHP4 microtime() compat wrappers

Trivially replaced with microtime( true ).

The following classes still use microtime() without the
argument, though I have chosen not to change them in this
commit because of a possible loss of precision:

* MWCryptHKDF
* UIDGenerator
* UpdateSpecialPages
* UploadStash

Change-Id: I4f594f6ada9e8fce3319b61844b9857d87e9aa99
---
M includes/normal/UtfNormalBench.php
M includes/normal/UtfNormalMemStress.php
M maintenance/convertLinks.php
M maintenance/mctest.php
4 files changed, 16 insertions(+), 44 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/18/147018/1

diff --git a/includes/normal/UtfNormalBench.php 
b/includes/normal/UtfNormalBench.php
index bd4cf05..bd2bc4e 100644
--- a/includes/normal/UtfNormalBench.php
+++ b/includes/normal/UtfNormalBench.php
@@ -81,20 +81,14 @@
        }
 }
 
-function benchTime() {
-       $st = explode( ' ', microtime() );
-
-       return (float)$st[0] + (float)$st[1];
-}
-
 function benchmarkForm( &$u, &$data, $form ) {
-       #$start = benchTime();
+       #$start = microtime( true );
        for ( $i = 0; $i < BENCH_CYCLES; $i++ ) {
-               $start = benchTime();
+               $start = microtime( true );
                $out = $u->$form( $data, UtfNormal::$utfCanonicalDecomp );
-               $deltas[] = ( benchTime() - $start );
+               $deltas[] = ( microtime( true ) - $start );
        }
-       #$delta = (benchTime() - $start) / BENCH_CYCLES;
+       #$delta = (microtime( true ) - $start) / BENCH_CYCLES;
        sort( $deltas );
        $delta = $deltas[0]; # Take shortest time
 
diff --git a/includes/normal/UtfNormalMemStress.php 
b/includes/normal/UtfNormalMemStress.php
index 14abf93..f133e4d 100644
--- a/includes/normal/UtfNormalMemStress.php
+++ b/includes/normal/UtfNormalMemStress.php
@@ -83,20 +83,14 @@
        }
 }
 
-function benchTime() {
-       $st = explode( ' ', microtime() );
-
-       return (float)$st[0] + (float)$st[1];
-}
-
 function benchmarkForm( &$u, &$data, $form ) {
-       #$start = benchTime();
+       #$start = microtime( true );
        for ( $i = 0; $i < BENCH_CYCLES; $i++ ) {
-               $start = benchTime();
+               $start = microtime( true );
                $out = $u->$form( $data, UtfNormal::$utfCanonicalDecomp );
-               $deltas[] = ( benchTime() - $start );
+               $deltas[] = ( microtime( true ) - $start );
        }
-       #$delta = (benchTime() - $start) / BENCH_CYCLES;
+       #$delta = (microtime( true ) - $start) / BENCH_CYCLES;
        sort( $deltas );
        $delta = $deltas[0]; # Take shortest time
 
diff --git a/maintenance/convertLinks.php b/maintenance/convertLinks.php
index 11a81eb..221ebe3 100644
--- a/maintenance/convertLinks.php
+++ b/maintenance/convertLinks.php
@@ -140,7 +140,7 @@
                                        $this->logPerformance = false;
                                }
                        }
-                       $baseTime = $startTime = $this->getMicroTime();
+                       $baseTime = $startTime = microtime( true );
                        # Create a title -> cur_id map
                        $this->output( "Loading IDs from $cur table...\n" );
                        $this->performanceLog( $fh, "Reading $numRows rows from 
cur table...\n" );
@@ -161,7 +161,7 @@
                                        if ( ( $curRowsRead % 
$curReadReportInterval ) == 0 ) {
                                                $this->performanceLog(
                                                        $fh,
-                                                       $curRowsRead . " " . ( 
$this->getMicroTime() - $baseTime ) . "\n"
+                                                       $curRowsRead . " " . ( 
microtime( true ) - $baseTime ) . "\n"
                                                );
                                                $this->output( "\t$curRowsRead 
rows of $cur table read.\n" );
                                        }
@@ -172,7 +172,7 @@
                        $this->output( "Finished loading IDs.\n\n" );
                        $this->performanceLog(
                                $fh,
-                               "Took " . ( $this->getMicroTime() - $baseTime ) 
. " seconds to load IDs.\n\n"
+                               "Took " . ( microtime( true ) - $baseTime ) . " 
seconds to load IDs.\n\n"
                        );
 
                        # 
--------------------------------------------------------------------
@@ -181,7 +181,7 @@
                        # convert, and write to the new table.
                        $this->createTempTable();
                        $this->performanceLog( $fh, "Resetting timer.\n\n" );
-                       $baseTime = $this->getMicroTime();
+                       $baseTime = microtime( true );
                        $this->output( "Processing $numRows rows from $links 
table...\n" );
                        $this->performanceLog( $fh, "Processing $numRows rows 
from $links table...\n" );
                        $this->performanceLog( $fh, "rows inserted vs seconds 
elapsed:\n" );
@@ -226,7 +226,7 @@
                                                $this->output( " done. Total 
$totalTuplesInserted tuples inserted.\n" );
                                                $this->performanceLog(
                                                        $fh,
-                                                       $totalTuplesInserted . 
" " . ( $this->getMicroTime() - $baseTime ) . "\n"
+                                                       $totalTuplesInserted . 
" " . ( microtime( true ) - $baseTime ) . "\n"
                                                );
                                        }
                                }
@@ -239,7 +239,7 @@
                        );
                        $this->performanceLog(
                                $fh,
-                               "Total execution time: " . ( 
$this->getMicroTime() - $startTime ) . " seconds.\n"
+                               "Total execution time: " . ( microtime( true ) 
- $startTime ) . " seconds.\n"
                        );
                        if ( $this->logPerformance ) {
                                fclose( $fh );
@@ -299,12 +299,6 @@
                if ( $this->logPerformance ) {
                        fwrite( $fh, $text );
                }
-       }
-
-       private function getMicroTime() { # return time in seconds, with 
microsecond accuracy
-               list( $usec, $sec ) = explode( " ", microtime() );
-
-               return ( (float)$usec + (float)$sec );
        }
 }
 
diff --git a/maintenance/mctest.php b/maintenance/mctest.php
index da49e55..a97d2e1 100644
--- a/maintenance/mctest.php
+++ b/maintenance/mctest.php
@@ -78,7 +78,7 @@
                        $set = 0;
                        $incr = 0;
                        $get = 0;
-                       $time_start = $this->microtime_float();
+                       $time_start = microtime( true );
                        for ( $i = 1; $i <= $iterations; $i++ ) {
                                if ( $mcc->set( "test$i", $i ) ) {
                                        $set++;
@@ -95,20 +95,10 @@
                                        $get++;
                                }
                        }
-                       $exectime = $this->microtime_float() - $time_start;
+                       $exectime = microtime( true ) - $time_start;
 
                        $this->output( " set: $set   incr: $incr   get: $get 
time: $exectime", $server );
                }
-       }
-
-       /**
-        * Return microtime() as a float
-        * @return float
-        */
-       private function microtime_float() {
-               list( $usec, $sec ) = explode( " ", microtime() );
-
-               return ( (float)$usec + (float)$sec );
        }
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/147018
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f594f6ada9e8fce3319b61844b9857d87e9aa99
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to