r76319 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76318‎ | r76319 | r76320 >
Date:18:05, 8 November 2010
Author:maxsem
Status:deferred
Tags:
Comment:
Profiling for expensive methods
Modified paths:
  • /branches/Gadgets-work/Gadgets_body.php (modified) (history)

Diff [purge]

Index: branches/Gadgets-work/Gadgets_body.php
@@ -102,8 +102,10 @@
103103 */
104104 public static function beforePageDisplay( $out ) {
105105 global $wgUser;
 106+
106107 if ( !$wgUser->isLoggedIn() ) return true;
107108
 109+ wfProfileIn( __METHOD__ );
108110 //disable all gadgets on critical special pages
109111 //NOTE: $out->isUserJsAllowed() is tempting, but always fals if $wgAllowUserJs is false.
110112 // That would disable gadgets on wikis without user JS. Introducing $out->isJsAllowed()
@@ -112,12 +114,17 @@
113115 $title = $out->getTitle();
114116 if ( $title->isSpecial( 'Preferences' )
115117 || $title->isSpecial( 'Resetpass' )
116 - || $title->isSpecial( 'Userlogin' ) ) {
 118+ || $title->isSpecial( 'Userlogin' ) )
 119+ {
 120+ wfProfileOut( __METHOD__ );
117121 return true;
118122 }
119123
120124 $gadgets = Gadget::loadList();
121 - if ( !$gadgets ) return true;
 125+ if ( !$gadgets ) {
 126+ wfProfileOut( __METHOD__ );
 127+ return true;
 128+ }
122129
123130 $lb = new LinkBatch();
124131 $lb->setCaller( __METHOD__ );
@@ -143,6 +150,7 @@
144151 $done[$page] = true;
145152 self::applyScript( $page, $out );
146153 }
 154+ wfProfileOut( __METHOD__ );
147155
148156 return true;
149157 }
@@ -338,6 +346,7 @@
339347
340348 if ( $gadgets !== null ) return $gadgets;
341349
 350+ wfProfileIn( __METHOD__ );
342351 $struct = self::loadStructuredList();
343352 if ( !$struct ) {
344353 $gadgets = $struct;
@@ -348,6 +357,7 @@
349358 foreach ( $struct as $section => $entries ) {
350359 $gadgets = array_merge( $gadgets, $entries );
351360 }
 361+ wfProfileOut( __METHOD__ );
352362
353363 return $gadgets;
354364 }
@@ -386,16 +396,21 @@
387397 static $gadgets = null;
388398 if ( $gadgets !== null && $forceNewText === null ) return $gadgets;
389399
 400+ wfProfileIn( __METHOD__ );
390401 $key = wfMemcKey( 'gadgets-definition' );
391402
392403 if ( $forceNewText === null ) {
393404 //cached?
394405 $gadgets = $wgMemc->get( $key );
395 - if ( self::isValidList( $gadgets ) ) return $gadgets;
 406+ if ( self::isValidList( $gadgets ) ) {
 407+ wfProfileOut( __METHOD__ );
 408+ return $gadgets;
 409+ }
396410
397411 $g = wfMsgForContentNoTrans( "gadgets-definition" );
398412 if ( wfEmptyMsg( "gadgets-definition", $g ) ) {
399413 $gadgets = false;
 414+ wfProfileOut( __METHOD__ );
400415 return $gadgets;
401416 }
402417 } else {
@@ -424,6 +439,7 @@
425440 $wgMemc->set( $key, $gadgets, 60*60*24 );
426441 $source = $forceNewText !== null ? 'input text' : 'MediaWiki:Gadgets-definition';
427442 wfDebug( __METHOD__ . ": $source parsed, cache entry $key updated\n");
 443+ wfProfileOut( __METHOD__ );
428444
429445 return $gadgets;
430446 }

Status & tagging log