summaryrefslogtreecommitdiff
path: root/maintenance/benchmarks
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2012-05-03 13:01:35 +0200
committerPierre Schmitz <pierre@archlinux.de>2012-05-03 13:01:35 +0200
commitd9022f63880ce039446fba8364f68e656b7bf4cb (patch)
tree16b40fbf17bf7c9ee6f4ead25b16dd192378050a /maintenance/benchmarks
parent27cf83d177256813e2e802241085fce5dd0f3fb9 (diff)
Update to MediaWiki 1.19.0
Diffstat (limited to 'maintenance/benchmarks')
-rw-r--r--maintenance/benchmarks/Benchmarker.php3
-rw-r--r--maintenance/benchmarks/bench_HTTP_HTTPS.php4
-rw-r--r--maintenance/benchmarks/bench_delete_truncate.php4
-rw-r--r--maintenance/benchmarks/bench_if_switch.php4
-rw-r--r--maintenance/benchmarks/bench_strtr_str_replace.php4
-rw-r--r--maintenance/benchmarks/bench_wfIsWindows.php4
-rw-r--r--maintenance/benchmarks/benchmarkHooks.php80
-rw-r--r--maintenance/benchmarks/benchmarkPurge.php6
8 files changed, 101 insertions, 8 deletions
diff --git a/maintenance/benchmarks/Benchmarker.php b/maintenance/benchmarks/Benchmarker.php
index 57fb8759..0056c3c7 100644
--- a/maintenance/benchmarks/Benchmarker.php
+++ b/maintenance/benchmarks/Benchmarker.php
@@ -1,6 +1,7 @@
<?php
/**
* @defgroup Benchmark Benchmark
+ * @ingroup Maintenance
*/
/**
@@ -23,7 +24,7 @@
*
* @todo Report PHP version, OS ..
* @file
- * @ingroup Maintenance Benchmark
+ * @ingroup Benchmark
*/
require_once( dirname( __FILE__ ) . '/../Maintenance.php' );
diff --git a/maintenance/benchmarks/bench_HTTP_HTTPS.php b/maintenance/benchmarks/bench_HTTP_HTTPS.php
index 0038b2d1..cf62aadb 100644
--- a/maintenance/benchmarks/bench_HTTP_HTTPS.php
+++ b/maintenance/benchmarks/bench_HTTP_HTTPS.php
@@ -18,8 +18,8 @@
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @ingroup Maintenance
- * @author Platonides
+ * @ingroup Benchmark
+ * @author Platonides
*/
require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
diff --git a/maintenance/benchmarks/bench_delete_truncate.php b/maintenance/benchmarks/bench_delete_truncate.php
index 9fe9bea9..71385520 100644
--- a/maintenance/benchmarks/bench_delete_truncate.php
+++ b/maintenance/benchmarks/bench_delete_truncate.php
@@ -1,4 +1,8 @@
<?php
+/**
+ * @file
+ * @ingroup Benchmark
+ */
require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
diff --git a/maintenance/benchmarks/bench_if_switch.php b/maintenance/benchmarks/bench_if_switch.php
index 11c00b3c..dafce050 100644
--- a/maintenance/benchmarks/bench_if_switch.php
+++ b/maintenance/benchmarks/bench_if_switch.php
@@ -18,8 +18,8 @@
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @ingroup Maintenance
- * @author Platonides
+ * @ingroup Benchmark
+ * @author Platonides
*/
require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
diff --git a/maintenance/benchmarks/bench_strtr_str_replace.php b/maintenance/benchmarks/bench_strtr_str_replace.php
index ae576981..73ace2bd 100644
--- a/maintenance/benchmarks/bench_strtr_str_replace.php
+++ b/maintenance/benchmarks/bench_strtr_str_replace.php
@@ -1,4 +1,8 @@
<?php
+/**
+ * @file
+ * @ingroup Benchmark
+ */
require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
diff --git a/maintenance/benchmarks/bench_wfIsWindows.php b/maintenance/benchmarks/bench_wfIsWindows.php
index 4c35221d..4caebc5e 100644
--- a/maintenance/benchmarks/bench_wfIsWindows.php
+++ b/maintenance/benchmarks/bench_wfIsWindows.php
@@ -18,8 +18,8 @@
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @ingroup Maintenance
- * @author Platonides
+ * @ingroup Benchmark
+ * @author Platonides
*/
require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
diff --git a/maintenance/benchmarks/benchmarkHooks.php b/maintenance/benchmarks/benchmarkHooks.php
new file mode 100644
index 00000000..4ec26168
--- /dev/null
+++ b/maintenance/benchmarks/benchmarkHooks.php
@@ -0,0 +1,80 @@
+<?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( dirname( __FILE__ ) . '/Benchmarker.php' );
+
+class BenchmarkHooks extends Benchmarker {
+
+ public function __construct() {
+ parent::__construct();
+ $this->mDescription = 'Benchmark MediaWiki Hooks.';
+ }
+
+ public function execute() {
+ global $wgHooks;
+ $wgHooks['Test'] = array();
+
+ $time = $this->benchHooks();
+ $this->output( 'Empty hook: ' . $time . "\n" );
+
+ $wgHooks['Test'][] = array( $this, 'test' );
+ $time = $this->benchHooks();
+ $this->output( 'Loaded (one) hook: ' . $time . "\n" );
+
+ for( $i = 0; $i < 9; $i++ ) {
+ $wgHooks['Test'][] = array( $this, 'test' );
+ }
+ $time = $this->benchHooks();
+ $this->output( 'Loaded (ten) hook: ' . $time . "\n" );
+
+ for( $i = 0; $i < 90; $i++ ) {
+ $wgHooks['Test'][] = array( $this, 'test' );
+ }
+ $time = $this->benchHooks();
+ $this->output( 'Loaded (one hundred) hook: ' . $time . "\n" );
+ $this->output( "\n" );
+ }
+
+ /**
+ * @param $trials int
+ * @return string
+ */
+ private function benchHooks( $trials = 10 ) {
+ $start = wfTime();
+ for ( $i = 0; $i < $trials; $i++ ) {
+ wfRunHooks( 'Test' );
+ }
+ $delta = wfTime() - $start;
+ $pertrial = $delta / $trials;
+ return sprintf( "Took %6.2fs",
+ $pertrial );
+ }
+
+ /**
+ * @return bool
+ */
+ public function test() {
+ return true;
+ }
+}
+
+$maintClass = 'BenchmarkHooks';
+require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/benchmarks/benchmarkPurge.php b/maintenance/benchmarks/benchmarkPurge.php
index 4ab7aa10..e9d2ec7a 100644
--- a/maintenance/benchmarks/benchmarkPurge.php
+++ b/maintenance/benchmarks/benchmarkPurge.php
@@ -18,7 +18,7 @@
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @ingroup Maintenance
+ * @ingroup Benchmark
*/
require_once( dirname( __FILE__ ) . '/Benchmarker.php' );
@@ -54,6 +54,7 @@ class BenchmarkPurge extends Benchmarker {
* to benchmark Squid response times.
* @param $urls array A bunch of URLs to purge
* @param $trials int How many times to run the test?
+ * @return string
*/
private function benchSquid( $urls, $trials = 1 ) {
$start = wfTime();
@@ -70,6 +71,7 @@ class BenchmarkPurge extends Benchmarker {
/**
* Get an array of randomUrl()'s.
* @param $length int How many urls to add to the array
+ * @return array
*/
private function randomUrlList( $length ) {
$list = array();
@@ -82,6 +84,7 @@ class BenchmarkPurge extends Benchmarker {
/**
* Return a random URL of the wiki. Not necessarily an actual title in the
* database, but at least a URL that looks like one.
+ * @return string
*/
private function randomUrl() {
global $wgServer, $wgArticlePath;
@@ -91,6 +94,7 @@ class BenchmarkPurge extends Benchmarker {
/**
* Create a random title string (not necessarily a Title object).
* For use with randomUrl().
+ * @return string
*/
private function randomTitle() {
$str = '';