3 * Squid purge benchmark script
5 * @subpackage Maintenance
9 require_once( "commandLine.inc" );
12 function benchSquid( $urls, $trials = 1 ) {
14 for( $i = 0; $i < $trials; $i++
) {
15 SquidUpdate
::purge( $urls );
17 $delta = wfTime() - $start;
18 $pertrial = $delta / $trials;
19 $pertitle = $pertrial / count( $urls );
20 return sprintf( "%4d titles in %6.2fms (%6.2fms each)",
21 count( $urls ), $pertrial * 1000.0, $pertitle * 1000.0 );
25 function randomUrlList( $length ) {
27 for( $i = 0; $i < $length; $i++
) {
28 $list[] = randomUrl();
34 function randomUrl() {
35 global $wgServer, $wgArticlePath;
36 return $wgServer . str_replace( '$1', randomTitle(), $wgArticlePath );
40 function randomTitle() {
42 $length = mt_rand( 1, 20 );
43 for( $i = 0; $i < $length; $i++
) {
44 $str .= chr( mt_rand( ord('a'), ord('z') ) );
46 return ucfirst( $str );
50 wfDie( "Squid purge benchmark doesn't do much without squid support on.\n" );
52 printf( "There are %d defined squid servers:\n", count( $wgSquidServers ) );
53 #echo implode( "\n", $wgSquidServers ) . "\n";
54 if( isset( $options['count'] ) ) {
55 $lengths = array( intval( $options['count'] ) );
57 $lengths = array( 1, 10, 100 );
59 foreach( $lengths as $length ) {
60 $urls = randomUrlList( $length );
61 $trial = benchSquid( $urls );