X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2Fbenchmarks%2FbenchmarkParse.php;h=ce38dad6a0100bf5e5285b8bb4efdc1365e02bfe;hb=c732764ef4764c384eb9e2502ce249fb4a177bee;hp=b81f9fd4246fd69ef00165079e46a1057750e8a5;hpb=01da3da43d18b123fe3679a6af21f046a78180d5;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/benchmarks/benchmarkParse.php b/maintenance/benchmarks/benchmarkParse.php index b81f9fd424..ce38dad6a0 100644 --- a/maintenance/benchmarks/benchmarkParse.php +++ b/maintenance/benchmarks/benchmarkParse.php @@ -41,7 +41,10 @@ class BenchmarkParse extends Maintenance { parent::__construct(); $this->addDescription( 'Benchmark parse operation' ); $this->addArg( 'title', 'The name of the page to parse' ); - $this->addOption( 'cold', 'Don\'t repeat the parse operation to warm the cache' ); + $this->addOption( 'warmup', 'Repeat the parse operation this number of times to warm the cache', + false, true ); + $this->addOption( 'loops', 'Number of times to repeat parse operation post-warmup', + false, true ); $this->addOption( 'page-time', 'Use the version of the page which was current at the given time', false, true ); @@ -81,22 +84,30 @@ class BenchmarkParse extends Maintenance { exit( 1 ); } - if ( !$this->hasOption( 'cold' ) ) { + $warmup = $this->getOption( 'warmup', 1 ); + for ( $i = 0; $i < $warmup; $i++ ) { $this->runParser( $revision ); } + $loops = $this->getOption( 'loops', 1 ); + if ( $loops < 1 ) { + $this->error( 'Invalid number of loops specified', true ); + } $startUsage = getrusage(); $startTime = microtime( true ); - $this->runParser( $revision ); + for ( $i = 0; $i < $loops; $i++ ) { + $this->runParser( $revision ); + } $endUsage = getrusage(); $endTime = microtime( true ); printf( "CPU time = %.3f s, wall clock time = %.3f s\n", // CPU time - $endUsage['ru_utime.tv_sec'] + $endUsage['ru_utime.tv_usec'] * 1e-6 - - $startUsage['ru_utime.tv_sec'] - $startUsage['ru_utime.tv_usec'] * 1e-6, + ( $endUsage['ru_utime.tv_sec'] + $endUsage['ru_utime.tv_usec'] * 1e-6 + - $startUsage['ru_utime.tv_sec'] - $startUsage['ru_utime.tv_usec'] * 1e-6 ) / $loops, // Wall clock time - $endTime - $startTime ); + ( $endTime - $startTime ) / $loops + ); } /**