diff --git a/maintenance/benchmarks/Benchmarker.php b/maintenance/benchmarks/Benchmarker.php index 9bfebced5d1..1559ee959d9 100644 --- a/maintenance/benchmarks/Benchmarker.php +++ b/maintenance/benchmarks/Benchmarker.php @@ -94,6 +94,10 @@ abstract class Benchmarker extends Maintenance { // Run benchmarks $stat = new RunningStat(); for ( $i = 0; $i < $count; $i++ ) { + // Setup outside of time measure for each loop + if ( isset( $bench['setupEach'] ) ) { + $bench['setupEach'](); + } $t = microtime( true ); call_user_func_array( $bench['function'], $bench['args'] ); $t = ( microtime( true ) - $t ) * 1000; diff --git a/maintenance/benchmarks/benchmarkTitleValue.php b/maintenance/benchmarks/benchmarkTitleValue.php index c60f4bbe82c..6bd7953971b 100644 --- a/maintenance/benchmarks/benchmarkTitleValue.php +++ b/maintenance/benchmarks/benchmarkTitleValue.php @@ -83,14 +83,22 @@ class BenchmarkTitleValue extends Benchmarker { [ 'function' => [ $this, 'getPrefixedTextTitle' ], ], - [ + 'parseTitleValue cached' => [ 'function' => [ $this, 'parseTitleValue' ], 'setup' => [ $this, 'randomize' ], ], - [ + 'parseTitle cached' => [ 'function' => [ $this, 'parseTitle' ], 'setup' => [ $this, 'randomize' ], ], + 'parseTitleValue no cache' => [ + 'function' => [ $this, 'parseTitleValue' ], + 'setupEach' => [ $this, 'randomize' ], + ], + 'parseTitle no cache' => [ + 'function' => [ $this, 'parseTitle' ], + 'setupEach' => [ $this, 'randomize' ], + ], ] ); }