| Index: trunk/phase3/profileinfo.php |
| — | — | @@ -83,6 +83,8 @@ |
| 84 | 84 | var $time; |
| 85 | 85 | var $children; |
| 86 | 86 | |
| | 87 | + static $totaltime, $totalmemory, $totalcount; |
| | 88 | + |
| 87 | 89 | function __construct( $name, $count, $time, $memory ) { |
| 88 | 90 | $this->name = $name; |
| 89 | 91 | $this->count = $count; |
| — | — | @@ -95,8 +97,7 @@ |
| 96 | 98 | $this->children[] = $child; |
| 97 | 99 | } |
| 98 | 100 | |
| 99 | | - function display($indent = 0.0) { |
| 100 | | - global $expand, $totaltime, $totalmemory, $totalcount; |
| | 101 | + function display( $expand, $indent = 0.0 ) { |
| 101 | 102 | usort( $this->children, 'compare_point' ); |
| 102 | 103 | |
| 103 | 104 | $extet = ''; |
| — | — | @@ -121,19 +122,19 @@ |
| 122 | 123 | <td class="name" style="padding-left: <?php echo $indent ?>em;"> |
| 123 | 124 | <?php echo htmlspecialchars( $this->name() ) . $extet ?> |
| 124 | 125 | </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> |
| 127 | 128 | <td class="count"><?php echo $this->count() ?></td> |
| 128 | 129 | <td class="cpr"><?php echo round( sprintf( '%.2f', $this->callsPerRequest() ), 2 ) ?></td> |
| 129 | 130 | <td class="tpc"><?php echo round( sprintf( '%.2f', $this->timePerCall() ), 2 ) ?></td> |
| 130 | 131 | <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> |
| 133 | 134 | </tr> |
| 134 | 135 | <?php |
| 135 | 136 | if ( $ex ) { |
| 136 | 137 | foreach ( $this->children as $child ) { |
| 137 | | - $child->display( $indent + 2 ); |
| | 138 | + $child->display( $expand, $indent + 2 ); |
| 138 | 139 | } |
| 139 | 140 | } |
| 140 | 141 | } |
| — | — | @@ -163,18 +164,15 @@ |
| 164 | 165 | } |
| 165 | 166 | |
| 166 | 167 | function callsPerRequest() { |
| 167 | | - global $totalcount; |
| 168 | | - return @( $this->count / $totalcount ); |
| | 168 | + return @( $this->count / self::$totalcount ); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | function timePerRequest() { |
| 172 | | - global $totalcount; |
| 173 | | - return @( $this->time / $totalcount ); |
| | 172 | + return @( $this->time / self::$totalcount ); |
| 174 | 173 | } |
| 175 | 174 | |
| 176 | 175 | function memoryPerRequest() { |
| 177 | | - global $totalcount; |
| 178 | | - return @( $this->memory / $totalcount ); |
| | 176 | + return @( $this->memory / self::$totalcount ); |
| 179 | 177 | } |
| 180 | 178 | |
| 181 | 179 | function fmttime() { |
| — | — | @@ -244,9 +242,9 @@ |
| 245 | 243 | <th><a href="<?php echo getEscapedProfileUrl( false, 'memory_per_req' ) ?>">kb/req</a></th> |
| 246 | 244 | </tr> |
| 247 | 245 | <?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; |
| 251 | 249 | |
| 252 | 250 | function getEscapedProfileUrl( $_filter = false, $_sort = false, $_expand = false ) { |
| 253 | 251 | global $filter, $sort, $expand; |
| — | — | @@ -272,9 +270,9 @@ |
| 273 | 271 | foreach( $res as $o ) { |
| 274 | 272 | $next = new profile_point( $o->pf_name, $o->pf_count, $o->pf_time, $o->pf_memory ); |
| 275 | 273 | 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(); |
| 279 | 277 | } |
| 280 | 278 | if ( $last !== false ) { |
| 281 | 279 | if ( preg_match( "/^".preg_quote( $last->name(), "/" )."/", $next->name() ) ) { |
| — | — | @@ -302,12 +300,12 @@ |
| 303 | 301 | if ( strlen( $filter ) && !strstr( $point->name(), $filter ) ) |
| 304 | 302 | continue; |
| 305 | 303 | |
| 306 | | - $point->display(); |
| | 304 | + $point->display( $expand ); |
| 307 | 305 | } |
| 308 | 306 | ?> |
| 309 | 307 | </table> |
| 310 | 308 | |
| 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> |
| 313 | 311 | </body> |
| 314 | 312 | </html> |