MediaWiki  1.23.2
bench_utf8_title_check.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Benchmarker.php';
25 
32 class bench_utf8_title_check extends Benchmarker {
33 
34  private $canRun;
35 
36  private $data;
37 
38  public function __construct() {
39  parent::__construct();
40 
41  $this->data = array(
42  "",
43  "United States of America", // 7bit ASCII
44  "S%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e",
45  "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn",
46  // This comes from bug 36839
47  "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn%7C"
48  . "Catherine%20Willows%7CDavid%20Hodges%7CDavid%20Phillips%7CGil%20Grissom%7CGreg%20Sanders%7CHodges%7C"
49  . "Internet%20Movie%20Database%7CJim%20Brass%7CLady%20Heather%7C"
50  . "Les%20Experts%20(s%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e)%7CLes%20Experts%20:%20Manhattan%7C"
51  . "Les%20Experts%20:%20Miami%7CListe%20des%20personnages%20des%20Experts%7C"
52  . "Liste%20des%20%C3%A9pisodes%20des%20Experts%7CMod%C3%A8le%20discussion:Palette%20Les%20Experts%7C"
53  . "Nick%20Stokes%7CPersonnage%20de%20fiction%7CPersonnage%20fictif%7CPersonnage%20de%20fiction%7C"
54  . "Personnages%20r%C3%A9currents%20dans%20Les%20Experts%7CRaymond%20Langston%7CRiley%20Adams%7C"
55  . "Saison%201%20des%20Experts%7CSaison%2010%20des%20Experts%7CSaison%2011%20des%20Experts%7C"
56  . "Saison%2012%20des%20Experts%7CSaison%202%20des%20Experts%7CSaison%203%20des%20Experts%7C"
57  . "Saison%204%20des%20Experts%7CSaison%205%20des%20Experts%7CSaison%206%20des%20Experts%7C"
58  . "Saison%207%20des%20Experts%7CSaison%208%20des%20Experts%7CSaison%209%20des%20Experts%7C"
59  . "Sara%20Sidle%7CSofia%20Curtis%7CS%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e%7CWallace%20Langham%7C"
60  . "Warrick%20Brown%7CWendy%20Simms%7C%C3%89tats-Unis"
61  );
62 
63  $this->canRun = function_exists ( 'mb_check_encoding' );
64 
65  if ( $this->canRun ) {
66  $this->mDescription = "Benchmark for using a regexp vs. mb_check_encoding to check for UTF-8 encoding.";
67  mb_internal_encoding( 'UTF-8' );
68  } else {
69  $this->mDescription = "CANNOT RUN benchmark using mb_check_encoding: function not available.";
70  }
71  }
72 
73  public function execute() {
74  if ( !$this->canRun ) {
75  return;
76  }
77  $benchmarks = array();
78  foreach ($this->data as $val) {
79  $benchmarks[] = array(
80  'function' => array( $this, 'use_regexp' ),
81  'args' => array( rawurldecode ( $val ) )
82  );
83  $benchmarks[] = array(
84  'function' => array( $this, 'use_regexp_non_capturing' ),
85  'args' => array( rawurldecode ( $val ) )
86  );
87  $benchmarks[] = array(
88  'function' => array( $this, 'use_regexp_once_only' ),
89  'args' => array( rawurldecode ( $val ) )
90  );
91  $benchmarks[] = array(
92  'function' => array( $this, 'use_mb_check_encoding' ),
93  'args' => array( rawurldecode ( $val ) )
94  );
95  }
96  $this->bench( $benchmarks );
97  print $this->getFormattedResults();
98  }
99 
100  private $isutf8;
101 
102  function use_regexp( $s ) {
103  $this->isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
104  '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
105  }
106 
107  function use_regexp_non_capturing( $s ) {
108  // Same as above with a non-capturing subgroup.
109  $this->isutf8 = preg_match( '/^(?:[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
110  '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
111  }
112 
113  function use_regexp_once_only( $s ) {
114  // Same as above with a once-only subgroup.
115  $this->isutf8 = preg_match( '/^(?>[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
116  '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
117  }
118 
119  function use_mb_check_encoding( $s ) {
120  $this->isutf8 = mb_check_encoding( $s, 'UTF-8' );
121  }
122 
123 }
124 
125 $maintClass = 'bench_utf8_title_check';
126 require_once RUN_MAINTENANCE_IF_MAIN;
data
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
Definition: hooks.txt:6
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
Benchmarker\getFormattedResults
getFormattedResults()
Definition: Benchmarker.php:78
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
$s
$s
Definition: mergeMessageFileList.php:156
Benchmarker\bench
bench(array $benchs)
Definition: Benchmarker.php:45
$maintClass
$maintClass
Definition: attachLatest.php:91
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:37
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
Benchmarker\__construct
__construct()
Default constructor.
Definition: Benchmarker.php:40
Maintenance::execute
public function execute()
Definition: maintenance.txt:45