X-Git-Url: https://git.cyclocoop.org/%28%28?a=blobdiff_plain;f=maintenance%2Fbenchmarks%2FbenchmarkPurge.php;h=42c1eb78a39860b85423946fc225776ffa2f9c5c;hb=f2f31fadc7d3aba8588b1ea6410f92166de1ac0a;hp=0932ee5434d0194f3c16e83e3e424251060590ec;hpb=ea4340e126eb2657cc878af74d53b9991844fb6b;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/benchmarks/benchmarkPurge.php b/maintenance/benchmarks/benchmarkPurge.php index 0932ee5434..42c1eb78a3 100644 --- a/maintenance/benchmarks/benchmarkPurge.php +++ b/maintenance/benchmarks/benchmarkPurge.php @@ -21,7 +21,7 @@ * @ingroup Benchmark */ -require_once( __DIR__ . '/Benchmarker.php' ); +require_once __DIR__ . '/Benchmarker.php'; /** * Maintenance script that benchmarks Squid purge. @@ -29,7 +29,6 @@ require_once( __DIR__ . '/Benchmarker.php' ); * @ingroup Benchmark */ class BenchmarkPurge extends Benchmarker { - public function __construct() { parent::__construct(); $this->mDescription = "Benchmark the Squid purge functions."; @@ -57,8 +56,8 @@ class BenchmarkPurge extends Benchmarker { /** * Run a bunch of URLs through SquidUpdate::purge() * to benchmark Squid response times. - * @param $urls array A bunch of URLs to purge - * @param $trials int How many times to run the test? + * @param array $urls A bunch of URLs to purge + * @param int $trials How many times to run the test? * @return string */ private function benchSquid( $urls, $trials = 1 ) { @@ -69,13 +68,14 @@ class BenchmarkPurge extends Benchmarker { $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 ); } /** * Get an array of randomUrl()'s. - * @param $length int How many urls to add to the array + * @param int $length How many urls to add to the array * @return array */ private function randomUrlList( $length ) { @@ -83,6 +83,7 @@ class BenchmarkPurge extends Benchmarker { 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 ); } }