From 1120bbe202a8b63b67e53484384a3097d987e36d Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Tue, 15 Jul 2014 17:23:27 -0700 Subject: [PATCH] benchmarkParse.php: add options for HHVM testing --warmup makes a specified number of loops before measuring; --loops repeats parsing given number of times Change-Id: I18bff702fce1f97c4afc6c9fd618fdc1f3272732 --- maintenance/benchmarks/benchmarkParse.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) 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 + ); } /** -- 2.20.1