Preferences: Disable the 'skin' preference if there are no skins
[lhc/web/wiklou.git] / includes / normal / UtfNormalMemStress.php
index 9ae6f23..f133e4d 100644 (file)
  * @ingroup UtfNormal
  */
 
-if( PHP_SAPI != 'cli' ) {
+if ( PHP_SAPI != 'cli' ) {
        die( "Run me from the command line please.\n" );
 }
 
-if( isset( $_SERVER['argv'] ) && in_array( '--icu', $_SERVER['argv'] ) ) {
+if ( isset( $_SERVER['argv'] ) && in_array( '--icu', $_SERVER['argv'] ) ) {
        dl( 'php_utfnormal.so' );
 }
 
@@ -39,8 +39,8 @@ require_once 'UtfNormalUtil.php';
 require_once 'UtfNormal.php';
 
 define( 'BENCH_CYCLES', 1 );
-define( 'BIGSIZE', 1024 * 1024 * 10); // 10m
-ini_set('memory_limit', BIGSIZE + 120 * 1024 * 1024);
+define( 'BIGSIZE', 1024 * 1024 * 10 ); // 10m
+ini_set( 'memory_limit', BIGSIZE + 120 * 1024 * 1024 );
 
 $testfiles = array(
        'testdata/washington.txt' => 'English text',
@@ -51,7 +51,7 @@ $testfiles = array(
 );
 $normalizer = new UtfNormal;
 UtfNormal::loadData();
-foreach( $testfiles as $file => $desc ) {
+foreach ( $testfiles as $file => $desc ) {
        benchmarkTest( $normalizer, $file, $desc );
 }
 
@@ -61,19 +61,20 @@ function benchmarkTest( &$u, $filename, $desc ) {
        print "Testing $filename ($desc)...\n";
        $data = file_get_contents( $filename );
        $all = $data;
-       while (strlen($all) < BIGSIZE) {
+       while ( strlen( $all ) < BIGSIZE ) {
                $all .= $all;
        }
        $data = $all;
-       echo "Data is " . strlen($data) . " bytes.\n";
+       echo "Data is " . strlen( $data ) . " bytes.\n";
        $forms = array(
-        'quickIsNFCVerify',
+               'quickIsNFCVerify',
                'cleanUp',
-               );
-       foreach( $forms as $form ) {
-               if( is_array( $form ) ) {
+       );
+
+       foreach ( $forms as $form ) {
+               if ( is_array( $form ) ) {
                        $str = $data;
-                       foreach( $form as $step ) {
+                       foreach ( $form as $step ) {
                                $str = benchmarkForm( $u, $str, $step );
                        }
                } else {
@@ -82,29 +83,25 @@ function benchmarkTest( &$u, $filename, $desc ) {
        }
 }
 
-function benchTime() {
-       $st = explode( ' ', microtime() );
-       return (float)$st[0] + (float)$st[1];
-}
-
 function benchmarkForm( &$u, &$data, $form ) {
-       #$start = benchTime();
-       for( $i = 0; $i < BENCH_CYCLES; $i++ ) {
-               $start = benchTime();
+       #$start = microtime( true );
+       for ( $i = 0; $i < BENCH_CYCLES; $i++ ) {
+               $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
 
        $rate = intval( strlen( $data ) / $delta );
-       $same = (0 == strcmp( $data, $out ) );
+       $same = ( 0 == strcmp( $data, $out ) );
 
        printf( " %20s %6.1fms %12s bytes/s (%s)\n",
                $form,
-               $delta*1000.0,
+               $delta * 1000.0,
                number_format( $rate ),
-               ($same ? 'no change' : 'changed' ) );
+               ( $same ? 'no change' : 'changed' ) );
+
        return $out;
 }