MediaWiki REL1_28
bench_utf8_title_check.php
Go to the documentation of this file.
1<?php
24require_once __DIR__ . '/Benchmarker.php';
25
33 private $data;
34
35 public function __construct() {
36 parent::__construct();
37
38 // @codingStandardsIgnoreStart Ignore long line warnings.
39 $this->data = [
40 "",
41 "United States of America", // 7bit ASCII
42 "S%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e",
43 "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn",
44 // This comes from bug 36839
45 "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn%7C"
46 . "Catherine%20Willows%7CDavid%20Hodges%7CDavid%20Phillips%7CGil%20Grissom%7CGreg%20Sanders%7CHodges%7C"
47 . "Internet%20Movie%20Database%7CJim%20Brass%7CLady%20Heather%7C"
48 . "Les%20Experts%20(s%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e)%7CLes%20Experts%20:%20Manhattan%7C"
49 . "Les%20Experts%20:%20Miami%7CListe%20des%20personnages%20des%20Experts%7C"
50 . "Liste%20des%20%C3%A9pisodes%20des%20Experts%7CMod%C3%A8le%20discussion:Palette%20Les%20Experts%7C"
51 . "Nick%20Stokes%7CPersonnage%20de%20fiction%7CPersonnage%20fictif%7CPersonnage%20de%20fiction%7C"
52 . "Personnages%20r%C3%A9currents%20dans%20Les%20Experts%7CRaymond%20Langston%7CRiley%20Adams%7C"
53 . "Saison%201%20des%20Experts%7CSaison%2010%20des%20Experts%7CSaison%2011%20des%20Experts%7C"
54 . "Saison%2012%20des%20Experts%7CSaison%202%20des%20Experts%7CSaison%203%20des%20Experts%7C"
55 . "Saison%204%20des%20Experts%7CSaison%205%20des%20Experts%7CSaison%206%20des%20Experts%7C"
56 . "Saison%207%20des%20Experts%7CSaison%208%20des%20Experts%7CSaison%209%20des%20Experts%7C"
57 . "Sara%20Sidle%7CSofia%20Curtis%7CS%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e%7CWallace%20Langham%7C"
58 . "Warrick%20Brown%7CWendy%20Simms%7C%C3%89tats-Unis"
59 ];
60 // @codingStandardsIgnoreEnd
61
62 $this->addDescription( "Benchmark for using a regexp vs. mb_check_encoding " .
63 "to check for UTF-8 encoding." );
64 }
65
66 public function execute() {
67 $benchmarks = [];
68 foreach ( $this->data as $val ) {
69 $benchmarks[] = [
70 'function' => [ $this, 'use_regexp' ],
71 'args' => [ rawurldecode( $val ) ]
72 ];
73 $benchmarks[] = [
74 'function' => [ $this, 'use_regexp_non_capturing' ],
75 'args' => [ rawurldecode( $val ) ]
76 ];
77 $benchmarks[] = [
78 'function' => [ $this, 'use_regexp_once_only' ],
79 'args' => [ rawurldecode( $val ) ]
80 ];
81 $benchmarks[] = [
82 'function' => [ $this, 'use_mb_check_encoding' ],
83 'args' => [ rawurldecode( $val ) ]
84 ];
85 }
86 $this->bench( $benchmarks );
88 }
89
90 private $isutf8;
91
92 function use_regexp( $s ) {
93 $this->isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
94 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
95 }
96
98 // Same as above with a non-capturing subgroup.
99 $this->isutf8 = preg_match( '/^(?:[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
100 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
101 }
102
104 // Same as above with a once-only subgroup.
105 $this->isutf8 = preg_match( '/^(?>[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
106 '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
107 }
108
110 $this->isutf8 = mb_check_encoding( $s, 'UTF-8' );
111 }
112}
113
114$maintClass = 'BenchUtf8TitleCheck';
115require_once RUN_MAINTENANCE_IF_MAIN;
This little benchmark executes the regexp formerly used in Language->checkTitleEncoding() and compare...
__construct()
Default constructor.
execute()
Do the actual work.
Base class for benchmark scripts.
bench(array $benchs)
addDescription( $text)
Set the description text.
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
while(( $__line=Maintenance::readconsole()) !==false) print
Definition eval.php:64
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
require_once RUN_MAINTENANCE_IF_MAIN
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a and VARBINARY columns should simply be TEXT The only exception is when VARBINARY is used to store true binary data
Definition postgres.txt:43