r112488 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112487‎ | r112488 | r112489 >
Date:15:03, 27 February 2012
Author:maxsem
Status:ok
Tags:
Comment:
profiling
Modified paths:
  • /trunk/extensions/MobileFrontend/ApiParseExtender.php (modified) (history)
  • /trunk/extensions/MobileFrontend/ApiQueryExcerpt.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/ApiQueryExcerpt.php
@@ -11,8 +11,10 @@
1212 }
1313
1414 public function execute() {
 15+ wfProfileIn( __METHOD__ );
1516 $titles = $this->getPageSet()->getGoodTitles();
1617 if ( count( $titles ) == 0 ) {
 18+ wfProfileOut( __METHOD__ );
1719 return;
1820 }
1921 $params = $this->extractRequestParams();
@@ -40,6 +42,7 @@
4143 break;
4244 }
4345 }
 46+ wfProfileOut( __METHOD__ );
4447 }
4548
4649 /**
@@ -50,15 +53,18 @@
5154 private function getExcerpt( Title $title, $plainText ) {
5255 global $wgMemc;
5356
 57+ wfProfileIn( __METHOD__ );
5458 $page = WikiPage::factory( $title );
5559 $key = wfMemcKey( 'mf', 'excerpt', $plainText, $title->getArticleID(), $page->getLatest() );
5660 $text = $wgMemc->get( $key );
5761 if ( $text !== false ) {
 62+ wfProfileOut( __METHOD__ );
5863 return $text;
5964 }
6065 $text = $this->parse( $page );
6166 $text = $this->convertText( $text, $title, $plainText );
6267 $wgMemc->set( $key, $text );
 68+ wfProfileOut( __METHOD__ );
6369 return $text;
6470 }
6571
@@ -68,6 +74,7 @@
6975 * @return string
7076 */
7177 private function parse( WikiPage $page ) {
 78+ wfProfileIn( __METHOD__ );
7279 if ( !$this->parserOptions ) {
7380 $this->parserOptions = new ParserOptions( new User( '127.0.0.1' ) );
7481 }
@@ -76,7 +83,9 @@
7784 $pout = ParserCache::singleton()->get( $page, $this->parserOptions );
7885 if ( $pout ) {
7986 $text = $pout->getText();
80 - return preg_replace( '/<h[1-6].*$/s', '', $text );
 87+ $s = preg_replace( '/<h[1-6].*$/s', '', $text );
 88+ wfProfileOut( __METHOD__ );
 89+ return $s;
8190 }
8291 }
8392 // in case of cache miss, render just the needed section
@@ -86,6 +95,7 @@
8796 $apiParse = new ApiParse( $apiMain, 'parse' );
8897 $apiParse->execute();
8998 $data = $apiParse->getResultData();
 99+ wfProfileOut( __METHOD__ );
90100 return $data['parse']['text']['*'];
91101 }
92102
@@ -97,6 +107,7 @@
98108 * @return string
99109 */
100110 private function convertText( $text, Title $title, $plainText ) {
 111+ wfProfileIn( __METHOD__ );
101112 $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text, false ), $title, 'XHTML' );
102113 $mf->removeImages();
103114 $mf->remove( array( 'table', 'div', 'sup.reference', 'span.coordinates', 'span.geo-multi-punct', 'span.geo-nondefault' ) );
@@ -111,6 +122,7 @@
112123 if ( $plainText ) {
113124 $text = html_entity_decode( $text );
114125 }
 126+ wfProfileOut( __METHOD__ );
115127 return trim( $text );
116128 }
117129
@@ -124,8 +136,10 @@
125137 private function trimText( $text, $requestedLength, $plainText ) {
126138 global $wgUseTidy;
127139
 140+ wfProfileIn( __METHOD__ );
128141 $length = mb_strlen( $text );
129142 if ( $length <= $requestedLength ) {
 143+ wfProfileOut( __METHOD__ );
130144 return $text;
131145 }
132146 $pattern = "#^.{{$requestedLength}}[\\w/]*>?#su";
@@ -136,6 +150,7 @@
137151 $text = trim ( MWTidy::tidy( $text ) );
138152 }
139153 $text .= wfMessage( 'ellipsis' )->inContentLanguage()->text();
 154+ wfProfileOut( __METHOD__ );
140155 return $text;
141156 }
142157
Index: trunk/extensions/MobileFrontend/ApiParseExtender.php
@@ -57,6 +57,7 @@
5858 */
5959 public static function onAPIAfterExecute( ApiBase &$module ) {
6060 if ( $module->getModuleName() == 'parse' ) {
 61+ wfProfileIn( __METHOD__ );
6162 $data = $module->getResultData();
6263 $params = $module->extractRequestParams();
6364 if ( isset( $data['parse']['text'] ) && isset( $params['mobileformat'] ) ) {
@@ -84,6 +85,7 @@
8586
8687 $result->addValue( null, $module->getModuleName(), $data['parse'] );
8788 }
 89+ wfProfileOut( __METHOD__ );
8890 }
8991 return true;
9092 }

Status & tagging log