summaryrefslogtreecommitdiff
path: root/maintenance/benchmarks
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /maintenance/benchmarks
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'maintenance/benchmarks')
-rw-r--r--maintenance/benchmarks/Benchmarker.php16
-rw-r--r--maintenance/benchmarks/bench_HTTP_HTTPS.php12
-rw-r--r--maintenance/benchmarks/bench_delete_truncate.php36
-rw-r--r--maintenance/benchmarks/bench_if_switch.php10
-rw-r--r--maintenance/benchmarks/bench_strtr_str_replace.php26
-rw-r--r--maintenance/benchmarks/bench_utf8_title_check.php126
-rw-r--r--maintenance/benchmarks/bench_wfIsWindows.php12
-rw-r--r--maintenance/benchmarks/benchmarkHooks.php17
-rw-r--r--maintenance/benchmarks/benchmarkPurge.php13
9 files changed, 241 insertions, 27 deletions
diff --git a/maintenance/benchmarks/Benchmarker.php b/maintenance/benchmarks/Benchmarker.php
index 0056c3c7..c198e0ff 100644
--- a/maintenance/benchmarks/Benchmarker.php
+++ b/maintenance/benchmarks/Benchmarker.php
@@ -5,7 +5,7 @@
*/
/**
- * Create a doxygen subgroup of Maintenance for benchmarks
+ * Base code for benchmark scripts.
*
* 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
@@ -27,7 +27,13 @@
* @ingroup Benchmark
*/
-require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
+require_once( __DIR__ . '/../Maintenance.php' );
+
+/**
+ * Base class for benchmark scripts.
+ *
+ * @ingroup Benchmark
+ */
abstract class Benchmarker extends Maintenance {
private $results;
@@ -47,11 +53,11 @@ abstract class Benchmarker extends Maintenance {
}
$bench_number++;
- $start = wfTime();
+ $start = microtime( true );
for( $i=0; $i<$count; $i++ ) {
call_user_func_array( $bench['function'], $bench['args'] );
}
- $delta = wfTime() - $start;
+ $delta = microtime( true ) - $start;
// function passed as a callback
if( is_array( $bench['function'] ) ) {
@@ -61,7 +67,7 @@ abstract class Benchmarker extends Maintenance {
$this->results[$bench_number] = array(
'function' => $bench['function'],
- 'arguments' => $bench['args'],
+ 'arguments' => $bench['args'],
'count' => $count,
'delta' => $delta,
'average' => $delta / $count,
diff --git a/maintenance/benchmarks/bench_HTTP_HTTPS.php b/maintenance/benchmarks/bench_HTTP_HTTPS.php
index cf62aadb..fa76ae22 100644
--- a/maintenance/benchmarks/bench_HTTP_HTTPS.php
+++ b/maintenance/benchmarks/bench_HTTP_HTTPS.php
@@ -1,6 +1,8 @@
<?php
/**
- * This come from r75429 message
+ * 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
@@ -22,7 +24,13 @@
* @author Platonides
*/
-require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
+require_once( __DIR__ . '/Benchmarker.php' );
+
+/**
+ * Maintenance script that benchmarks HTTP request vs HTTPS request.
+ *
+ * @ingroup Benchmark
+ */
class bench_HTTP_HTTPS extends Benchmarker {
public function __construct() {
diff --git a/maintenance/benchmarks/bench_delete_truncate.php b/maintenance/benchmarks/bench_delete_truncate.php
index 71385520..d9741496 100644
--- a/maintenance/benchmarks/bench_delete_truncate.php
+++ b/maintenance/benchmarks/bench_delete_truncate.php
@@ -1,11 +1,33 @@
<?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( dirname( __FILE__ ) . '/Benchmarker.php' );
+require_once( __DIR__ . '/Benchmarker.php' );
+/**
+ * Maintenance script that benchmarks SQL DELETE vs SQL TRUNCATE.
+ *
+ * @ingroup Benchmark
+ */
class BenchmarkDeleteTruncate extends Benchmarker {
public function __construct() {
@@ -24,24 +46,24 @@ class BenchmarkDeleteTruncate extends Benchmarker {
$this->insertData( $dbw );
- $start = wfTime();
+ $start = microtime( true );
$this->delete( $dbw );
- $end = wfTime();
+ $end = microtime( true );
- echo "Delete: " . $end - $start;
+ echo "Delete: " . sprintf( "%6.3fms", ( $end - $start ) * 1000 );
echo "\r\n";
$this->insertData( $dbw );
- $start = wfTime();
+ $start = microtime( true );
$this->truncate( $dbw );
- $end = wfTime();
+ $end = microtime( true );
- echo "Truncate: " . $end - $start;
+ echo "Truncate: " . sprintf( "%6.3fms", ( $end - $start ) * 1000 );
echo "\r\n";
$dbw->dropTable( 'test' );
diff --git a/maintenance/benchmarks/bench_if_switch.php b/maintenance/benchmarks/bench_if_switch.php
index dafce050..1f590d4d 100644
--- a/maintenance/benchmarks/bench_if_switch.php
+++ b/maintenance/benchmarks/bench_if_switch.php
@@ -1,5 +1,7 @@
<?php
/**
+ * Benchmark if elseif... versus switch case.
+ *
* This come from r75429 message
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +24,13 @@
* @author Platonides
*/
-require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
+require_once( __DIR__ . '/Benchmarker.php' );
+
+/**
+ * Maintenance script that benchmark if elseif... versus switch case.
+ *
+ * @ingroup Maintenance
+ */
class bench_if_switch extends Benchmarker {
public function __construct() {
diff --git a/maintenance/benchmarks/bench_strtr_str_replace.php b/maintenance/benchmarks/bench_strtr_str_replace.php
index 73ace2bd..9fa7c8e3 100644
--- a/maintenance/benchmarks/bench_strtr_str_replace.php
+++ b/maintenance/benchmarks/bench_strtr_str_replace.php
@@ -1,10 +1,29 @@
<?php
/**
+ * Benchmark for strtr() vs str_replace().
+ *
+ * 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
*/
-require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
+require_once( __DIR__ . '/Benchmarker.php' );
function bfNormalizeTitleStrTr( $str ) {
return strtr( $str, '_', ' ' );
@@ -14,6 +33,11 @@ function bfNormalizeTitleStrReplace( $str ) {
return str_replace( '_', ' ', $str );
}
+/**
+ * Maintenance script that benchmarks for strtr() vs str_replace().
+ *
+ * @ingroup Benchmark
+ */
class bench_strtr_str_replace extends Benchmarker {
public function __construct() {
diff --git a/maintenance/benchmarks/bench_utf8_title_check.php b/maintenance/benchmarks/bench_utf8_title_check.php
new file mode 100644
index 00000000..f5987800
--- /dev/null
+++ b/maintenance/benchmarks/bench_utf8_title_check.php
@@ -0,0 +1,126 @@
+<?php
+/**
+ * Benchmark for using a regexp vs. mb_check_encoding to check for UTF-8 encoding.
+ *
+ * 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__ . '/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.
+ *
+ * @ingroup Benchmark
+ */
+class bench_utf8_title_check extends Benchmarker {
+
+ private $canRun;
+
+ private $data;
+
+ public function __construct() {
+ parent::__construct();
+
+ $this->data = array (
+ "",
+ "United States of America", // 7bit ASCII
+ "S%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e",
+ "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn",
+ // This comes from bug 36839
+ "Acteur%7CAlbert%20Robbins%7CAnglais%7CAnn%20Donahue%7CAnthony%20E.%20Zuiker%7CCarol%20Mendelsohn%7C"
+ . "Catherine%20Willows%7CDavid%20Hodges%7CDavid%20Phillips%7CGil%20Grissom%7CGreg%20Sanders%7CHodges%7C"
+ . "Internet%20Movie%20Database%7CJim%20Brass%7CLady%20Heather%7C"
+ . "Les%20Experts%20(s%C3%A9rie%20t%C3%A9l%C3%A9vis%C3%A9e)%7CLes%20Experts%20:%20Manhattan%7C"
+ . "Les%20Experts%20:%20Miami%7CListe%20des%20personnages%20des%20Experts%7C"
+ . "Liste%20des%20%C3%A9pisodes%20des%20Experts%7CMod%C3%A8le%20discussion:Palette%20Les%20Experts%7C"
+ . "Nick%20Stokes%7CPersonnage%20de%20fiction%7CPersonnage%20fictif%7CPersonnage%20de%20fiction%7C"
+ . "Personnages%20r%C3%A9currents%20dans%20Les%20Experts%7CRaymond%20Langston%7CRiley%20Adams%7C"
+ . "Saison%201%20des%20Experts%7CSaison%2010%20des%20Experts%7CSaison%2011%20des%20Experts%7C"
+ . "Saison%2012%20des%20Experts%7CSaison%202%20des%20Experts%7CSaison%203%20des%20Experts%7C"
+ . "Saison%204%20des%20Experts%7CSaison%205%20des%20Experts%7CSaison%206%20des%20Experts%7C"
+ . "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"
+ );
+
+ $this->canRun = function_exists ( 'mb_check_encoding' );
+
+ if ( $this->canRun ) {
+ $this->mDescription = "Benchmark for using a regexp vs. mb_check_encoding to check for UTF-8 encoding.";
+ mb_internal_encoding( 'UTF-8' );
+ } else {
+ $this->mDescription = "CANNOT RUN benchmark using mb_check_encoding: function not available.";
+ }
+ }
+
+ public function execute() {
+ if ( !$this->canRun ) {
+ return;
+ }
+ $benchmarks = array();
+ 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 ) )
+ );
+ }
+ $this->bench( $benchmarks );
+ print $this->getFormattedResults();
+ }
+
+ private $isutf8;
+
+ function use_regexp( $s ) {
+ $this->isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
+ '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
+ }
+
+ function use_regexp_non_capturing( $s ) {
+ // Same as above with a non-capturing subgroup.
+ $this->isutf8 = preg_match( '/^(?:[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
+ '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
+ }
+
+ function use_regexp_once_only( $s ) {
+ // Same as above with a once-only subgroup.
+ $this->isutf8 = preg_match( '/^(?>[\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
+ '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
+ }
+
+ function use_mb_check_encoding( $s ) {
+ $this->isutf8 = mb_check_encoding( $s, 'UTF-8' );
+ }
+
+}
+
+$maintClass = 'bench_utf8_title_check';
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/benchmarks/bench_wfIsWindows.php b/maintenance/benchmarks/bench_wfIsWindows.php
index 4caebc5e..85439827 100644
--- a/maintenance/benchmarks/bench_wfIsWindows.php
+++ b/maintenance/benchmarks/bench_wfIsWindows.php
@@ -1,6 +1,8 @@
<?php
/**
- * This come from r75429 message
+ * Benchmark for wfIsWindows().
+ *
+ * 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
@@ -22,7 +24,13 @@
* @author Platonides
*/
-require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
+require_once( __DIR__ . '/Benchmarker.php' );
+
+/**
+ * Maintenance script that benchmarks wfIsWindows().
+ *
+ * @ingroup Benchmark
+ */
class bench_wfIsWindows extends Benchmarker {
public function __construct() {
diff --git a/maintenance/benchmarks/benchmarkHooks.php b/maintenance/benchmarks/benchmarkHooks.php
index 4ec26168..fdb016f4 100644
--- a/maintenance/benchmarks/benchmarkHooks.php
+++ b/maintenance/benchmarks/benchmarkHooks.php
@@ -1,5 +1,7 @@
<?php
/**
+ * Benchmark %MediaWiki hooks.
+ *
* 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
@@ -19,8 +21,13 @@
* @ingroup Benchmark
*/
-require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
+require_once( __DIR__ . '/Benchmarker.php' );
+/**
+ * Maintenance script that benchmarks %MediaWiki hooks.
+ *
+ * @ingroup Benchmark
+ */
class BenchmarkHooks extends Benchmarker {
public function __construct() {
@@ -58,14 +65,14 @@ class BenchmarkHooks extends Benchmarker {
* @return string
*/
private function benchHooks( $trials = 10 ) {
- $start = wfTime();
+ $start = microtime( true );
for ( $i = 0; $i < $trials; $i++ ) {
wfRunHooks( 'Test' );
}
- $delta = wfTime() - $start;
+ $delta = microtime( true ) - $start;
$pertrial = $delta / $trials;
- return sprintf( "Took %6.2fs",
- $pertrial );
+ return sprintf( "Took %6.3fms",
+ $pertrial * 1000 );
}
/**
diff --git a/maintenance/benchmarks/benchmarkPurge.php b/maintenance/benchmarks/benchmarkPurge.php
index e9d2ec7a..ec686b2a 100644
--- a/maintenance/benchmarks/benchmarkPurge.php
+++ b/maintenance/benchmarks/benchmarkPurge.php
@@ -1,6 +1,6 @@
<?php
/**
- * Squid purge benchmark script
+ * Benchmark for Squid purge.
*
* 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
@@ -21,8 +21,13 @@
* @ingroup Benchmark
*/
-require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
+require_once( __DIR__ . '/Benchmarker.php' );
+/**
+ * Maintenance script that benchmarks Squid purge.
+ *
+ * @ingroup Benchmark
+ */
class BenchmarkPurge extends Benchmarker {
public function __construct() {
@@ -57,11 +62,11 @@ class BenchmarkPurge extends Benchmarker {
* @return string
*/
private function benchSquid( $urls, $trials = 1 ) {
- $start = wfTime();
+ $start = microtime( true );
for ( $i = 0; $i < $trials; $i++ ) {
SquidUpdate::purge( $urls );
}
- $delta = wfTime() - $start;
+ $delta = microtime( true ) - $start;
$pertrial = $delta / $trials;
$pertitle = $pertrial / count( $urls );
return sprintf( "%4d titles in %6.2fms (%6.2fms each)",