diff options
-rw-r--r-- | autoload.php | 5 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_HTTP_HTTPS.php | 70 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_Wikimedia_base_convert.php | 77 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_delete_truncate.php | 105 | ||||
-rw-r--r-- | maintenance/benchmarks/bench_if_switch.php | 115 | ||||
-rw-r--r-- | maintenance/benchmarks/benchmarkStringReplacement.php | 55 |
6 files changed, 0 insertions, 427 deletions
diff --git a/autoload.php b/autoload.php index e8ab20629cbe..365dc0160689 100644 --- a/autoload.php +++ b/autoload.php @@ -186,18 +186,13 @@ $wgAutoloadLocalClasses = [ 'BatchRowUpdate' => __DIR__ . '/includes/utils/BatchRowUpdate.php', 'BatchRowWriter' => __DIR__ . '/includes/utils/BatchRowWriter.php', 'BcryptPassword' => __DIR__ . '/includes/password/BcryptPassword.php', - 'BenchHttpHttps' => __DIR__ . '/maintenance/benchmarks/bench_HTTP_HTTPS.php', - 'BenchIfSwitch' => __DIR__ . '/maintenance/benchmarks/bench_if_switch.php', 'BenchUtf8TitleCheck' => __DIR__ . '/maintenance/benchmarks/bench_utf8_title_check.php', - 'BenchWikimediaBaseConvert' => __DIR__ . '/maintenance/benchmarks/bench_Wikimedia_base_convert.php', - 'BenchmarkDeleteTruncate' => __DIR__ . '/maintenance/benchmarks/bench_delete_truncate.php', 'BenchmarkHooks' => __DIR__ . '/maintenance/benchmarks/benchmarkHooks.php', 'BenchmarkJSMinPlus' => __DIR__ . '/maintenance/benchmarks/benchmarkJSMinPlus.php', 'BenchmarkLruHash' => __DIR__ . '/maintenance/benchmarks/benchmarkLruHash.php', 'BenchmarkParse' => __DIR__ . '/maintenance/benchmarks/benchmarkParse.php', 'BenchmarkPurge' => __DIR__ . '/maintenance/benchmarks/benchmarkPurge.php', 'BenchmarkSanitizer' => __DIR__ . '/maintenance/benchmarks/benchmarkSanitizer.php', - 'BenchmarkStringReplacement' => __DIR__ . '/maintenance/benchmarks/benchmarkStringReplacement.php', 'BenchmarkTidy' => __DIR__ . '/maintenance/benchmarks/benchmarkTidy.php', 'BenchmarkTitleValue' => __DIR__ . '/maintenance/benchmarks/benchmarkTitleValue.php', 'Benchmarker' => __DIR__ . '/maintenance/includes/Benchmarker.php', diff --git a/maintenance/benchmarks/bench_HTTP_HTTPS.php b/maintenance/benchmarks/bench_HTTP_HTTPS.php deleted file mode 100644 index 71d86711d8c6..000000000000 --- a/maintenance/benchmarks/bench_HTTP_HTTPS.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php -/** - * Benchmark HTTP request vs HTTPS request. - * - * This come from r75429 message. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @ingroup Benchmark - * @author Platonides - */ - -use MediaWiki\MediaWikiServices; - -require_once __DIR__ . '/../includes/Benchmarker.php'; - -/** - * Maintenance script that benchmarks HTTP request vs HTTPS request. - * - * @ingroup Benchmark - */ -class BenchHttpHttps extends Benchmarker { - public function __construct() { - parent::__construct(); - $this->addDescription( 'Benchmark HTTP request vs HTTPS request.' ); - } - - public function execute() { - $this->bench( [ - [ 'function' => [ $this, 'getHTTP' ] ], - [ 'function' => [ $this, 'getHTTPS' ] ], - ] ); - } - - private function doRequest( $proto ) { - MediaWikiServices::getInstance()->getHttpRequestFactory()-> - get( "$proto://localhost/", [], __METHOD__ ); - } - - /** - * bench function 1 - */ - protected function getHTTP() { - $this->doRequest( 'http' ); - } - - /** - * bench function 2 - */ - protected function getHTTPS() { - $this->doRequest( 'https' ); - } -} - -$maintClass = BenchHttpHttps::class; -require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_Wikimedia_base_convert.php b/maintenance/benchmarks/bench_Wikimedia_base_convert.php deleted file mode 100644 index 6e3e1262480f..000000000000 --- a/maintenance/benchmarks/bench_Wikimedia_base_convert.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * Benchmark for Wikimedia\base_convert() - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @ingroup Benchmark - * @author Tyler Romeo - */ - -require_once __DIR__ . '/../includes/Benchmarker.php'; - -/** - * Maintenance script that benchmarks Wikimedia\base_convert(). - * - * Code exists in vendor repository brought in via composer. - * - * @ingroup Benchmark - */ -class BenchWikimediaBaseConvert extends Benchmarker { - public function __construct() { - parent::__construct(); - $this->addDescription( 'Benchmark for Wikimedia\base_convert.' ); - $this->addOption( "inbase", "Input base", false, true ); - $this->addOption( "outbase", "Output base", false, true ); - $this->addOption( "length", "Size in digits to generate for input", false, true ); - } - - public function execute() { - $inbase = $this->getOption( "inbase", 36 ); - $outbase = $this->getOption( "outbase", 16 ); - $length = $this->getOption( "length", 128 ); - $number = self::makeRandomNumber( $inbase, $length ); - - $this->bench( [ - [ - 'function' => 'Wikimedia\base_convert', - 'args' => [ $number, $inbase, $outbase, 0, true, 'php' ] - ], - [ - 'function' => 'Wikimedia\base_convert', - 'args' => [ $number, $inbase, $outbase, 0, true, 'bcmath' ] - ], - [ - 'function' => 'Wikimedia\base_convert', - 'args' => [ $number, $inbase, $outbase, 0, true, 'gmp' ] - ], - ] ); - } - - protected static function makeRandomNumber( $base, $length ) { - $baseChars = '0123456789abcdefghijklmnopqrstuvwxyz'; - $res = ''; - for ( $i = 0; $i < $length; $i++ ) { - $res .= $baseChars[mt_rand( 0, $base - 1 )]; - } - - return $res; - } -} - -$maintClass = BenchWikimediaBaseConvert::class; -require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_delete_truncate.php b/maintenance/benchmarks/bench_delete_truncate.php deleted file mode 100644 index 2a26e86b1991..000000000000 --- a/maintenance/benchmarks/bench_delete_truncate.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Benchmark SQL DELETE vs SQL TRUNCATE. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @ingroup Benchmark - */ - -require_once __DIR__ . '/../includes/Benchmarker.php'; - -use Wikimedia\Rdbms\IDatabase; -use Wikimedia\Rdbms\IMaintainableDatabase; - -/** - * Maintenance script that benchmarks SQL DELETE vs SQL TRUNCATE. - * - * @ingroup Benchmark - */ -class BenchmarkDeleteTruncate extends Benchmarker { - protected $defaultCount = 10; - - public function __construct() { - parent::__construct(); - $this->addDescription( 'Benchmarks SQL DELETE vs SQL TRUNCATE.' ); - } - - public function execute() { - $dbw = $this->getDB( DB_PRIMARY ); - - $test = $dbw->tableName( 'test' ); - $dbw->query( "CREATE TABLE IF NOT EXISTS /*_*/$test ( - test_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, - text varbinary(255) NOT NULL -);", __METHOD__ ); - - $this->bench( [ - 'Delete' => [ - 'setup' => function () use ( $dbw ) { - $this->insertData( $dbw ); - }, - 'function' => function () use ( $dbw ) { - $this->delete( $dbw ); - } - ], - 'Truncate' => [ - 'setup' => function () use ( $dbw ) { - $this->insertData( $dbw ); - }, - 'function' => function () use ( $dbw ) { - $this->truncate( $dbw ); - } - ] - ] ); - - $dbw->dropTable( 'test', __METHOD__ ); - } - - /** - * @param IDatabase $dbw - * @return void - */ - private function insertData( $dbw ) { - $range = range( 0, 1024 ); - $data = []; - foreach ( $range as $r ) { - $data[] = [ 'text' => $r ]; - } - $dbw->insert( 'test', $data, __METHOD__ ); - } - - /** - * @param IDatabase $dbw - * @return void - */ - private function delete( $dbw ) { - $dbw->delete( 'text', '*', __METHOD__ ); - } - - /** - * @param IMaintainableDatabase $dbw - * @return void - */ - private function truncate( $dbw ) { - $test = $dbw->tableName( 'test' ); - $dbw->query( "TRUNCATE TABLE $test", __METHOD__ ); - } -} - -$maintClass = BenchmarkDeleteTruncate::class; -require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/bench_if_switch.php b/maintenance/benchmarks/bench_if_switch.php deleted file mode 100644 index 1e0d3eb2337d..000000000000 --- a/maintenance/benchmarks/bench_if_switch.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php -/** - * Benchmark if elseif... versus switch case. - * - * This come from r75429 message - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @ingroup Benchmark - * @author Platonides - */ - -require_once __DIR__ . '/../includes/Benchmarker.php'; - -/** - * Maintenance script that benchmark if elseif... versus switch case. - * - * @ingroup Maintenance - */ -class BenchIfSwitch extends Benchmarker { - public function __construct() { - parent::__construct(); - $this->addDescription( 'Benchmark if elseif... versus switch case.' ); - } - - public function execute() { - $this->bench( [ - [ 'function' => [ $this, 'doElseIf' ] ], - [ 'function' => [ $this, 'doSwitch' ] ], - ] ); - } - - /** - * bench function 1 - * @suppress PhanSuspiciousValueComparison - */ - protected function doElseIf() { - $a = 'z'; - if ( $a == 'a' ) { - } elseif ( $a == 'b' ) { - } elseif ( $a == 'c' ) { - } elseif ( $a == 'd' ) { - } elseif ( $a == 'e' ) { - } elseif ( $a == 'f' ) { - } elseif ( $a == 'g' ) { - } elseif ( $a == 'h' ) { - } elseif ( $a == 'i' ) { - } elseif ( $a == 'j' ) { - } elseif ( $a == 'k' ) { - } elseif ( $a == 'l' ) { - } elseif ( $a == 'm' ) { - } elseif ( $a == 'n' ) { - } elseif ( $a == 'o' ) { - } elseif ( $a == 'p' ) { - } else { - } - } - - /** - * bench function 2 - */ - protected function doSwitch() { - $a = 'z'; - switch ( $a ) { - case 'b': - break; - case 'c': - break; - case 'd': - break; - case 'e': - break; - case 'f': - break; - case 'g': - break; - case 'h': - break; - case 'i': - break; - case 'j': - break; - case 'k': - break; - case 'l': - break; - case 'm': - break; - case 'n': - break; - case 'o': - break; - case 'p': - break; - default: - } - } -} - -$maintClass = BenchIfSwitch::class; -require_once RUN_MAINTENANCE_IF_MAIN; diff --git a/maintenance/benchmarks/benchmarkStringReplacement.php b/maintenance/benchmarks/benchmarkStringReplacement.php deleted file mode 100644 index a0c84426ade1..000000000000 --- a/maintenance/benchmarks/benchmarkStringReplacement.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/** - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @ingroup Benchmark - */ - -require_once __DIR__ . '/../includes/Benchmarker.php'; - -/** - * Maintenance script that benchmarks string replacement methods. - * - * @ingroup Benchmark - */ -class BenchmarkStringReplacement extends Benchmarker { - protected $defaultCount = 10000; - private $input = 'MediaWiki:Some_random_test_page'; - - public function __construct() { - parent::__construct(); - $this->addDescription( 'Benchmark for string replacement methods.' ); - } - - public function execute() { - $this->bench( [ - 'strtr' => [ $this, 'bench_strtr' ], - 'str_replace' => [ $this, 'bench_str_replace' ], - ] ); - } - - protected function bench_strtr() { - strtr( $this->input, "_", " " ); - } - - protected function bench_str_replace() { - str_replace( "_", " ", $this->input ); - } -} - -$maintClass = BenchmarkStringReplacement::class; -require_once RUN_MAINTENANCE_IF_MAIN; |