r73953 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73952‎ | r73953 | r73954 >
Date:16:05, 29 September 2010
Author:platonides
Status:ok
Tags:
Comment:
Move some globals into the class.
Modified paths:
  • /trunk/phase3/profileinfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/profileinfo.php
@@ -83,6 +83,8 @@
8484 var $time;
8585 var $children;
8686
 87+ static $totaltime, $totalmemory, $totalcount;
 88+
8789 function __construct( $name, $count, $time, $memory ) {
8890 $this->name = $name;
8991 $this->count = $count;
@@ -95,8 +97,7 @@
9698 $this->children[] = $child;
9799 }
98100
99 - function display($indent = 0.0) {
100 - global $expand, $totaltime, $totalmemory, $totalcount;
 101+ function display( $expand, $indent = 0.0 ) {
101102 usort( $this->children, 'compare_point' );
102103
103104 $extet = '';
@@ -121,19 +122,19 @@
122123 <td class="name" style="padding-left: <?php echo $indent ?>em;">
123124 <?php echo htmlspecialchars( $this->name() ) . $extet ?>
124125 </td>
125 - <td class="timep"><?php echo @wfPercent( $this->time() / $totaltime * 100 ) ?></td>
126 - <td class="memoryp"><?php echo @wfPercent( $this->memory() / $totalmemory * 100 ) ?></td>
 126+ <td class="timep"><?php echo @wfPercent( $this->time() / self::$totaltime * 100 ) ?></td>
 127+ <td class="memoryp"><?php echo @wfPercent( $this->memory() / self::$totalmemory * 100 ) ?></td>
127128 <td class="count"><?php echo $this->count() ?></td>
128129 <td class="cpr"><?php echo round( sprintf( '%.2f', $this->callsPerRequest() ), 2 ) ?></td>
129130 <td class="tpc"><?php echo round( sprintf( '%.2f', $this->timePerCall() ), 2 ) ?></td>
130131 <td class="mpc"><?php echo round( sprintf( '%.2f' ,$this->memoryPerCall() / 1024 ), 2 ) ?></td>
131 - <td class="tpr"><?php echo @round( sprintf( '%.2f', $this->time() / $totalcount ), 2 ) ?></td>
132 - <td class="mpr"><?php echo @round( sprintf( '%.2f' ,$this->memory() / $totalcount / 1024 ), 2 ) ?></td>
 132+ <td class="tpr"><?php echo @round( sprintf( '%.2f', $this->time() / self::$totalcount ), 2 ) ?></td>
 133+ <td class="mpr"><?php echo @round( sprintf( '%.2f' ,$this->memory() / self::$totalcount / 1024 ), 2 ) ?></td>
133134 </tr>
134135 <?php
135136 if ( $ex ) {
136137 foreach ( $this->children as $child ) {
137 - $child->display( $indent + 2 );
 138+ $child->display( $expand, $indent + 2 );
138139 }
139140 }
140141 }
@@ -163,18 +164,15 @@
164165 }
165166
166167 function callsPerRequest() {
167 - global $totalcount;
168 - return @( $this->count / $totalcount );
 168+ return @( $this->count / self::$totalcount );
169169 }
170170
171171 function timePerRequest() {
172 - global $totalcount;
173 - return @( $this->time / $totalcount );
 172+ return @( $this->time / self::$totalcount );
174173 }
175174
176175 function memoryPerRequest() {
177 - global $totalcount;
178 - return @( $this->memory / $totalcount );
 176+ return @( $this->memory / self::$totalcount );
179177 }
180178
181179 function fmttime() {
@@ -244,9 +242,9 @@
245243 <th><a href="<?php echo getEscapedProfileUrl( false, 'memory_per_req' ) ?>">kb/req</a></th>
246244 </tr>
247245 <?php
248 -$totaltime = 0.0;
249 -$totalcount = 0;
250 -$totalmemory = 0.0;
 246+profile_point::$totaltime = 0.0;
 247+profile_point::$totalcount = 0;
 248+profile_point::$totalmemory = 0.0;
251249
252250 function getEscapedProfileUrl( $_filter = false, $_sort = false, $_expand = false ) {
253251 global $filter, $sort, $expand;
@@ -272,9 +270,9 @@
273271 foreach( $res as $o ) {
274272 $next = new profile_point( $o->pf_name, $o->pf_count, $o->pf_time, $o->pf_memory );
275273 if( $next->name() == '-total' ) {
276 - $totaltime = $next->time();
277 - $totalcount = $next->count();
278 - $totalmemory = $next->memory();
 274+ profile_point::$totaltime = $next->time();
 275+ profile_point::$totalcount = $next->count();
 276+ profile_point::$totalmemory = $next->memory();
279277 }
280278 if ( $last !== false ) {
281279 if ( preg_match( "/^".preg_quote( $last->name(), "/" )."/", $next->name() ) ) {
@@ -302,12 +300,12 @@
303301 if ( strlen( $filter ) && !strstr( $point->name(), $filter ) )
304302 continue;
305303
306 - $point->display();
 304+ $point->display( $expand );
307305 }
308306 ?>
309307 </table>
310308
311 -<p>Total time: <tt><?php printf("%5.02f", $totaltime) ?></tt></p>
312 -<p>Total memory: <tt><?php printf("%5.02f", $totalmemory / 1024 ) ?></tt></p>
 309+<p>Total time: <tt><?php printf("%5.02f", profile_point::$totaltime) ?></tt></p>
 310+<p>Total memory: <tt><?php printf("%5.02f", profile_point::$totalmemory / 1024 ) ?></tt></p>
313311 </body>
314312 </html>

Status & tagging log