MediaWiki  1.23.2
benchmarkPurge.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/Benchmarker.php';
25 
31 class BenchmarkPurge extends Benchmarker {
32 
33  public function __construct() {
34  parent::__construct();
35  $this->mDescription = "Benchmark the Squid purge functions.";
36  }
37 
38  public function execute() {
39  global $wgUseSquid, $wgSquidServers;
40  if ( !$wgUseSquid ) {
41  $this->error( "Squid purge benchmark doesn't do much without squid support on.", true );
42  } else {
43  $this->output( "There are " . count( $wgSquidServers ) . " defined squid servers:\n" );
44  if ( $this->hasOption( 'count' ) ) {
45  $lengths = array( intval( $this->getOption( 'count' ) ) );
46  } else {
47  $lengths = array( 1, 10, 100 );
48  }
49  foreach ( $lengths as $length ) {
50  $urls = $this->randomUrlList( $length );
51  $trial = $this->benchSquid( $urls );
52  $this->output( $trial . "\n" );
53  }
54  }
55  }
56 
64  private function benchSquid( $urls, $trials = 1 ) {
65  $start = microtime( true );
66  for ( $i = 0; $i < $trials; $i++ ) {
67  SquidUpdate::purge( $urls );
68  }
69  $delta = microtime( true ) - $start;
70  $pertrial = $delta / $trials;
71  $pertitle = $pertrial / count( $urls );
72  return sprintf( "%4d titles in %6.2fms (%6.2fms each)",
73  count( $urls ), $pertrial * 1000.0, $pertitle * 1000.0 );
74  }
75 
81  private function randomUrlList( $length ) {
82  $list = array();
83  for ( $i = 0; $i < $length; $i++ ) {
84  $list[] = $this->randomUrl();
85  }
86  return $list;
87  }
88 
94  private function randomUrl() {
95  global $wgServer, $wgArticlePath;
96  return $wgServer . str_replace( '$1', $this->randomTitle(), $wgArticlePath );
97  }
98 
104  private function randomTitle() {
105  $str = '';
106  $length = mt_rand( 1, 20 );
107  for ( $i = 0; $i < $length; $i++ ) {
108  $str .= chr( mt_rand( ord( 'a' ), ord( 'z' ) ) );
109  }
110  return ucfirst( $str );
111  }
112 }
113 
114 $maintClass = "BenchmarkPurge";
115 require_once RUN_MAINTENANCE_IF_MAIN;
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
BenchmarkPurge\__construct
__construct()
Default constructor.
Definition: benchmarkPurge.php:33
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
BenchmarkPurge\randomUrl
randomUrl()
Return a random URL of the wiki.
Definition: benchmarkPurge.php:94
BenchmarkPurge\execute
execute()
Do the actual work.
Definition: benchmarkPurge.php:38
SquidUpdate\purge
static purge( $urlArr)
Purges a list of Squids defined in $wgSquidServers.
Definition: SquidUpdate.php:134
BenchmarkPurge
Maintenance script that benchmarks Squid purge.
Definition: benchmarkPurge.php:31
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
Benchmarker
Base class for benchmark scripts.
Definition: Benchmarker.php:37
$wgArticlePath
$wgArticlePath
Definition: img_auth.php:48
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:191
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
BenchmarkPurge\benchSquid
benchSquid( $urls, $trials=1)
Run a bunch of URLs through SquidUpdate::purge() to benchmark Squid response times.
Definition: benchmarkPurge.php:64
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular param exists.
Definition: Maintenance.php:181
BenchmarkPurge\randomTitle
randomTitle()
Create a random title string (not necessarily a Title object).
Definition: benchmarkPurge.php:104
$maintClass
$maintClass
Definition: benchmarkPurge.php:114
BenchmarkPurge\randomUrlList
randomUrlList( $length)
Get an array of randomUrl()'s.
Definition: benchmarkPurge.php:81