r99921 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99920‎ | r99921 | r99922 >
Date:22:23, 15 October 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Refactor out duplicate code

Add 10 subscribers. Can we have 10 of the same?
Modified paths:
  • /trunk/phase3/maintenance/benchmarks/benchmarkHooks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/benchmarks/benchmarkHooks.php
@@ -29,31 +29,25 @@
3030 }
3131
3232 public function execute() {
33 - $time = $this->benchEmptyHooks();
34 - $this->output( 'Empty hook: ' . $time . "\n" );
35 - $time = $this->benchLoadedHooks();
36 - $this->output( 'Loaded hook: ' . $time . "\n" );
37 - $this->output( "\n" );
38 - }
39 -
40 - private function benchEmptyHooks( $trials = 1 ) {
4133 global $wgHooks;
4234 $wgHooks['Test'] = array();
4335
44 - $start = wfTime();
45 - for ( $i = 0; $i < $trials; $i++ ) {
46 - wfRunHooks( 'Test' );
47 - }
48 - $delta = wfTime() - $start;
49 - $pertrial = $delta / $trials;
50 - return sprintf( "Took %6.2fms",
51 - $pertrial );
52 - }
 36+ $time = $this->benchHooks();
 37+ $this->output( 'Empty hook: ' . $time . "\n" );
5338
54 - private function benchLoadedHooks( $trials = 1 ) {
55 - global $wgHooks;
5639 $wgHooks['Test'][] = array( $this, 'test' );
 40+ $time = $this->benchHooks();
 41+ $this->output( 'Loaded (one) hook: ' . $time . "\n" );
5742
 43+ for( $i = 0; $i < 9; $i++ ) {
 44+ $wgHooks['Test'][] = array( $this, 'test' );
 45+ }
 46+ $time = $this->benchHooks();
 47+ $this->output( 'Loaded (ten) hook: ' . $time . "\n" );
 48+ $this->output( "\n" );
 49+ }
 50+
 51+ private function benchHooks( $trials = 1 ) {
5852 $start = wfTime();
5953 for ( $i = 0; $i < $trials; $i++ ) {
6054 wfRunHooks( 'Test' );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99919Rudimentary hook benchmarksreedy22:15, 15 October 2011

Comments

#Comment by Krinkle (talk | contribs)   22:46, 17 October 2011

Follows up r99919

Status & tagging log