MediaWiki REL1_35
benchmarkStringReplacement.php
Go to the documentation of this file.
1<?php
22require_once __DIR__ . '/../includes/Benchmarker.php';
23
30 protected $defaultCount = 10000;
31 private $input = 'MediaWiki:Some_random_test_page';
32
33 public function __construct() {
34 parent::__construct();
35 $this->addDescription( 'Benchmark for string replacement methods.' );
36 }
37
38 public function execute() {
39 $this->bench( [
40 'strtr' => [ $this, 'bench_strtr' ],
41 'str_replace' => [ $this, 'bench_str_replace' ],
42 ] );
43 }
44
45 protected function bench_strtr() {
46 strtr( $this->input, "_", " " );
47 }
48
49 protected function bench_str_replace() {
50 str_replace( "_", " ", $this->input );
51 }
52}
53
54$maintClass = BenchmarkStringReplacement::class;
55require_once RUN_MAINTENANCE_IF_MAIN;
const RUN_MAINTENANCE_IF_MAIN
Maintenance script that benchmarks string replacement methods.
Base class for benchmark scripts.
bench(array $benchs)
addDescription( $text)
Set the description text.