summaryrefslogtreecommitdiff
path: root/includes/normal/UtfNormalBench.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /includes/normal/UtfNormalBench.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/normal/UtfNormalBench.php')
-rw-r--r--includes/normal/UtfNormalBench.php39
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;
}