MediaWiki  1.23.14
UtfNormalMemStress.php
Go to the documentation of this file.
1 <?php
29 if( PHP_SAPI != 'cli' ) {
30  die( "Run me from the command line please.\n" );
31 }
32 
33 if( isset( $_SERVER['argv'] ) && in_array( '--icu', $_SERVER['argv'] ) ) {
34  dl( 'php_utfnormal.so' );
35 }
36 
37 require_once 'UtfNormalDefines.php';
38 require_once 'UtfNormalUtil.php';
39 require_once 'UtfNormal.php';
40 
41 define( 'BENCH_CYCLES', 1 );
42 define( 'BIGSIZE', 1024 * 1024 * 10); // 10m
43 ini_set('memory_limit', BIGSIZE + 120 * 1024 * 1024);
44 
46  'testdata/washington.txt' => 'English text',
47  'testdata/berlin.txt' => 'German text',
48  'testdata/bulgakov.txt' => 'Russian text',
49  'testdata/tokyo.txt' => 'Japanese text',
50  'testdata/young.txt' => 'Korean text'
51 );
54 foreach( $testfiles as $file => $desc ) {
55  benchmarkTest( $normalizer, $file, $desc );
56 }
57 
58 # -------
59 
60 function benchmarkTest( &$u, $filename, $desc ) {
61  print "Testing $filename ($desc)...\n";
62  $data = file_get_contents( $filename );
63  $all = $data;
64  while (strlen($all) < BIGSIZE) {
65  $all .= $all;
66  }
67  $data = $all;
68  echo "Data is " . strlen($data) . " bytes.\n";
69  $forms = array(
70  'quickIsNFCVerify',
71  'cleanUp',
72  );
73  foreach( $forms as $form ) {
74  if( is_array( $form ) ) {
75  $str = $data;
76  foreach( $form as $step ) {
77  $str = benchmarkForm( $u, $str, $step );
78  }
79  } else {
80  benchmarkForm( $u, $data, $form );
81  }
82  }
83 }
84 
85 function benchTime() {
86  $st = explode( ' ', microtime() );
87  return (float)$st[0] + (float)$st[1];
88 }
89 
90 function benchmarkForm( &$u, &$data, $form ) {
91  #$start = benchTime();
92  for( $i = 0; $i < BENCH_CYCLES; $i++ ) {
93  $start = benchTime();
94  $out = $u->$form( $data, UtfNormal::$utfCanonicalDecomp );
95  $deltas[] = (benchTime() - $start);
96  }
97  #$delta = (benchTime() - $start) / BENCH_CYCLES;
98  sort( $deltas );
99  $delta = $deltas[0]; # Take shortest time
100 
101  $rate = intval( strlen( $data ) / $delta );
102  $same = (0 == strcmp( $data, $out ) );
103 
104  printf( " %20s %6.1fms %12s bytes/s (%s)\n",
105  $form,
106  $delta*1000.0,
107  number_format( $rate ),
108  ($same ? 'no change' : 'changed' ) );
109  return $out;
110 }
benchTime
benchTime()
Definition: UtfNormalMemStress.php:85
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
BENCH_CYCLES
const BENCH_CYCLES
Definition: UtfNormalMemStress.php:41
benchmarkTest
foreach( $testfiles as $file=> $desc) benchmarkTest(&$u, $filename, $desc)
Definition: UtfNormalMemStress.php:60
$form
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead $form
Definition: hooks.txt:2584
UtfNormal\$utfCanonicalDecomp
static $utfCanonicalDecomp
Definition: UtfNormal.php:62
$testfiles
$testfiles
Definition: UtfNormalMemStress.php:45
$out
$out
Definition: UtfNormalGenerate.php:167
UtfNormal
Unicode normalization routines for working with UTF-8 strings.
Definition: UtfNormal.php:48
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$normalizer
$normalizer
Definition: UtfNormalMemStress.php:52
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
BIGSIZE
const BIGSIZE
Definition: UtfNormalMemStress.php:42
UtfNormal\loadData
static loadData()
Load the basic composition data if necessary.
Definition: UtfNormal.php:191
benchmarkForm
benchmarkForm(&$u, &$data, $form)
Definition: UtfNormalMemStress.php:90