3 * Squid purge benchmark script
4 * @addtogroup Maintenance
8 require_once( "commandLine.inc" );
11 function benchSquid( $urls, $trials = 1 ) {
13 for( $i = 0; $i < $trials; $i++
) {
14 SquidUpdate
::purge( $urls );
16 $delta = wfTime() - $start;
17 $pertrial = $delta / $trials;
18 $pertitle = $pertrial / count( $urls );
19 return sprintf( "%4d titles in %6.2fms (%6.2fms each)",
20 count( $urls ), $pertrial * 1000.0, $pertitle * 1000.0 );
24 function randomUrlList( $length ) {
26 for( $i = 0; $i < $length; $i++
) {
27 $list[] = randomUrl();
33 function randomUrl() {
34 global $wgServer, $wgArticlePath;
35 return $wgServer . str_replace( '$1', randomTitle(), $wgArticlePath );
39 function randomTitle() {
41 $length = mt_rand( 1, 20 );
42 for( $i = 0; $i < $length; $i++
) {
43 $str .= chr( mt_rand( ord('a'), ord('z') ) );
45 return ucfirst( $str );
49 wfDie( "Squid purge benchmark doesn't do much without squid support on.\n" );
51 printf( "There are %d defined squid servers:\n", count( $wgSquidServers ) );
52 #echo implode( "\n", $wgSquidServers ) . "\n";
53 if( isset( $options['count'] ) ) {
54 $lengths = array( intval( $options['count'] ) );
56 $lengths = array( 1, 10, 100 );
58 foreach( $lengths as $length ) {
59 $urls = randomUrlList( $length );
60 $trial = benchSquid( $urls );