Merge "HTMLForm: Do not generate wrappers for empty sections"
[lhc/web/wiklou.git] / maintenance / benchmarks / benchmarkPurge.php
index 1797358..e006cf5 100644 (file)
@@ -29,10 +29,9 @@ require_once __DIR__ . '/Benchmarker.php';
  * @ingroup Benchmark
  */
 class BenchmarkPurge extends Benchmarker {
-
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Benchmark the Squid purge functions.";
+               $this->addDescription( 'Benchmark the Squid purge functions.' );
        }
 
        public function execute() {
@@ -42,9 +41,9 @@ class BenchmarkPurge extends Benchmarker {
                } else {
                        $this->output( "There are " . count( $wgSquidServers ) . " defined squid servers:\n" );
                        if ( $this->hasOption( 'count' ) ) {
-                               $lengths = array( intval( $this->getOption( 'count' ) ) );
+                               $lengths = [ intval( $this->getOption( 'count' ) ) ];
                        } else {
-                               $lengths = array( 1, 10, 100 );
+                               $lengths = [ 1, 10, 100 ];
                        }
                        foreach ( $lengths as $length ) {
                                $urls = $this->randomUrlList( $length );
@@ -64,11 +63,12 @@ class BenchmarkPurge extends Benchmarker {
        private function benchSquid( $urls, $trials = 1 ) {
                $start = microtime( true );
                for ( $i = 0; $i < $trials; $i++ ) {
-                       SquidUpdate::purge( $urls );
+                       CdnCacheUpdate::purge( $urls );
                }
                $delta = microtime( true ) - $start;
                $pertrial = $delta / $trials;
                $pertitle = $pertrial / count( $urls );
+
                return sprintf( "%4d titles in %6.2fms (%6.2fms each)",
                        count( $urls ), $pertrial * 1000.0, $pertitle * 1000.0 );
        }
@@ -79,10 +79,11 @@ class BenchmarkPurge extends Benchmarker {
         * @return array
         */
        private function randomUrlList( $length ) {
-               $list = array();
+               $list = [];
                for ( $i = 0; $i < $length; $i++ ) {
                        $list[] = $this->randomUrl();
                }
+
                return $list;
        }
 
@@ -93,6 +94,7 @@ class BenchmarkPurge extends Benchmarker {
         */
        private function randomUrl() {
                global $wgServer, $wgArticlePath;
+
                return $wgServer . str_replace( '$1', $this->randomTitle(), $wgArticlePath );
        }
 
@@ -107,6 +109,7 @@ class BenchmarkPurge extends Benchmarker {
                for ( $i = 0; $i < $length; $i++ ) {
                        $str .= chr( mt_rand( ord( 'a' ), ord( 'z' ) ) );
                }
+
                return ucfirst( $str );
        }
 }