MediaWiki REL1_30
benchmarkPurge.php
Go to the documentation of this file.
1<?php
24require_once __DIR__ . '/Benchmarker.php';
25
32 public function __construct() {
33 parent::__construct();
34 $this->addDescription( 'Benchmark the Squid purge functions.' );
35 }
36
37 public function execute() {
39 if ( !$wgUseSquid ) {
40 $this->error( "Squid purge benchmark doesn't do much without squid support on.", true );
41 } else {
42 $this->output( "There are " . count( $wgSquidServers ) . " defined squid servers:\n" );
43 if ( $this->hasOption( 'count' ) ) {
44 $lengths = [ intval( $this->getOption( 'count' ) ) ];
45 } else {
46 $lengths = [ 1, 10, 100 ];
47 }
48 foreach ( $lengths as $length ) {
49 $urls = $this->randomUrlList( $length );
50 $trial = $this->benchSquid( $urls );
51 $this->output( $trial . "\n" );
52 }
53 }
54 }
55
63 private function benchSquid( $urls, $trials = 1 ) {
64 $start = microtime( true );
65 for ( $i = 0; $i < $trials; $i++ ) {
67 }
68 $delta = microtime( true ) - $start;
69 $pertrial = $delta / $trials;
70 $pertitle = $pertrial / count( $urls );
71
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 = [];
83 for ( $i = 0; $i < $length; $i++ ) {
84 $list[] = $this->randomUrl();
85 }
86
87 return $list;
88 }
89
95 private function randomUrl() {
97
98 return $wgServer . str_replace( '$1', $this->randomTitle(), $wgArticlePath );
99 }
100
106 private function randomTitle() {
107 $str = '';
108 $length = mt_rand( 1, 20 );
109 for ( $i = 0; $i < $length; $i++ ) {
110 $str .= chr( mt_rand( ord( 'a' ), ord( 'z' ) ) );
111 }
112
113 return ucfirst( $str );
114 }
115}
116
117$maintClass = "BenchmarkPurge";
118require_once RUN_MAINTENANCE_IF_MAIN;
$wgUseSquid
Enable/disable CDN.
$wgSquidServers
List of proxy servers to purge on changes; default port is 80.
$wgServer
URL of the server.
$maintClass
Maintenance script that benchmarks Squid purge.
randomUrl()
Return a random URL of the wiki.
benchSquid( $urls, $trials=1)
Run a bunch of URLs through SquidUpdate::purge() to benchmark Squid response times.
__construct()
Default constructor.
randomTitle()
Create a random title string (not necessarily a Title object).
randomUrlList( $length)
Get an array of randomUrl()'s.
execute()
Do the actual work.
Base class for benchmark scripts.
static purge(array $urlArr)
Purges a list of CDN nodes defined in $wgSquidServers.
hasOption( $name)
Checks to see if a particular param exists.
addDescription( $text)
Set the description text.
getOption( $name, $default=null)
Get an option, or return the default.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
Definition hooks.txt:2581
$wgArticlePath
Definition img_auth.php:45
require_once RUN_MAINTENANCE_IF_MAIN