diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
commit | c9aa36da061816dee256a979c2ff8d2ee41824d9 (patch) | |
tree | 29f7002b80ee984b488bd047dbbd80b36bf892e9 /includes/normal/UtfNormalBench.php | |
parent | b4274e0e33eafb5e9ead9d949ebf031a9fb8363b (diff) | |
parent | d1ba966140d7a60cd5ae4e8667ceb27c1a138592 (diff) |
Merge branch 'archwiki'
# Conflicts:
# skins/ArchLinux.php
# skins/ArchLinux/archlogo.gif
Diffstat (limited to 'includes/normal/UtfNormalBench.php')
-rw-r--r-- | includes/normal/UtfNormalBench.php | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/includes/normal/UtfNormalBench.php b/includes/normal/UtfNormalBench.php index 89de9290..bd2bc4e4 100644 --- a/includes/normal/UtfNormalBench.php +++ b/includes/normal/UtfNormalBench.php @@ -3,7 +3,7 @@ * Approximate benchmark for some basic operations. * * Copyright © 2004 Brion Vibber <brion@pobox.com> - * http://www.mediawiki.org/ + * https://www.mediawiki.org/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,11 +24,11 @@ * @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' ); } @@ -47,7 +47,7 @@ $testfiles = array( ); $normalizer = new UtfNormal; UtfNormal::loadData(); -foreach( $testfiles as $file => $desc ) { +foreach ( $testfiles as $file => $desc ) { benchmarkTest( $normalizer, $file, $desc ); } @@ -67,11 +67,12 @@ function benchmarkTest( &$u, $filename, $desc ) { # 'NFD', 'NFKD', array( 'fastDecompose', 'fastCombiningSort', 'fastCompose' ), # 'quickIsNFC', 'quickIsNFCVerify', - ); - 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 { @@ -80,29 +81,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; } |