X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fbenchmarks%2Fbench_utf8_title_check.php;h=c92a7208680683c2c95cc8e8e5a620bc988dfa31;hb=c57d68a38d37860fa946e169b32833d171f4e4f8;hp=bd18adb228546d258cb51820355b53b58948c02c;hpb=b67ab9de01a2eb95875d27a26eb9c30b22edf97e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/benchmarks/bench_utf8_title_check.php b/maintenance/benchmarks/bench_utf8_title_check.php index bd18adb228..c92a720868 100644 --- a/maintenance/benchmarks/bench_utf8_title_check.php +++ b/maintenance/benchmarks/bench_utf8_title_check.php @@ -24,21 +24,19 @@ require_once __DIR__ . '/Benchmarker.php'; /** - * This little benchmark executes the regexp used in Language->checkTitleEncoding() - * and compares its execution time against that of mb_check_encoding, if available. + * This little benchmark executes the regexp formerly used in Language->checkTitleEncoding() + * and compares its execution time against that of mb_check_encoding. * * @ingroup Benchmark */ class BenchUtf8TitleCheck extends Benchmarker { - private $canRun; - private $data; public function __construct() { parent::__construct(); // @codingStandardsIgnoreStart Ignore long line warnings. - $this->data = array( + $this->data = [ "", "United States of America", // 7bit ASCII "S%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e", @@ -58,41 +56,32 @@ class BenchUtf8TitleCheck extends Benchmarker { . "Saison%207%20des%20Experts%7CSaison%208%20des%20Experts%7CSaison%209%20des%20Experts%7C" . "Sara%20Sidle%7CSofia%20Curtis%7CS%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e%7CWallace%20Langham%7C" . "Warrick%20Brown%7CWendy%20Simms%7C%C3%89tats-Unis" - ); + ]; // @codingStandardsIgnoreEnd - $this->canRun = function_exists( 'mb_check_encoding' ); - - if ( $this->canRun ) { - $this->addDescription( "Benchmark for using a regexp vs. mb_check_encoding " . - "to check for UTF-8 encoding." ); - } else { - $this->addDescription( 'CANNOT RUN benchmark using mb_check_encoding: function not available.' ); - } + $this->addDescription( "Benchmark for using a regexp vs. mb_check_encoding " . + "to check for UTF-8 encoding." ); } public function execute() { - if ( !$this->canRun ) { - return; - } - $benchmarks = array(); + $benchmarks = []; foreach ( $this->data as $val ) { - $benchmarks[] = array( - 'function' => array( $this, 'use_regexp' ), - 'args' => array( rawurldecode( $val ) ) - ); - $benchmarks[] = array( - 'function' => array( $this, 'use_regexp_non_capturing' ), - 'args' => array( rawurldecode( $val ) ) - ); - $benchmarks[] = array( - 'function' => array( $this, 'use_regexp_once_only' ), - 'args' => array( rawurldecode( $val ) ) - ); - $benchmarks[] = array( - 'function' => array( $this, 'use_mb_check_encoding' ), - 'args' => array( rawurldecode( $val ) ) - ); + $benchmarks[] = [ + 'function' => [ $this, 'use_regexp' ], + 'args' => [ rawurldecode( $val ) ] + ]; + $benchmarks[] = [ + 'function' => [ $this, 'use_regexp_non_capturing' ], + 'args' => [ rawurldecode( $val ) ] + ]; + $benchmarks[] = [ + 'function' => [ $this, 'use_regexp_once_only' ], + 'args' => [ rawurldecode( $val ) ] + ]; + $benchmarks[] = [ + 'function' => [ $this, 'use_mb_check_encoding' ], + 'args' => [ rawurldecode( $val ) ] + ]; } $this->bench( $benchmarks ); print $this->getFormattedResults();