From: Platonides Date: Wed, 29 Sep 2010 16:05:46 +0000 (+0000) Subject: Move some globals into the class. X-Git-Tag: 1.31.0-rc.0~34748 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=8a0282e238f665c1f71eff5724c1961d7d38ec79;p=lhc%2Fweb%2Fwiklou.git Move some globals into the class. --- diff --git a/profileinfo.php b/profileinfo.php index 2329f6a41e..ccf59fecab 100644 --- a/profileinfo.php +++ b/profileinfo.php @@ -83,6 +83,8 @@ class profile_point { var $time; var $children; + static $totaltime, $totalmemory, $totalcount; + function __construct( $name, $count, $time, $memory ) { $this->name = $name; $this->count = $count; @@ -95,8 +97,7 @@ class profile_point { $this->children[] = $child; } - function display($indent = 0.0) { - global $expand, $totaltime, $totalmemory, $totalcount; + function display( $expand, $indent = 0.0 ) { usort( $this->children, 'compare_point' ); $extet = ''; @@ -121,19 +122,19 @@ class profile_point { name() ) . $extet ?> - time() / $totaltime * 100 ) ?> - memory() / $totalmemory * 100 ) ?> + time() / self::$totaltime * 100 ) ?> + memory() / self::$totalmemory * 100 ) ?> count() ?> callsPerRequest() ), 2 ) ?> timePerCall() ), 2 ) ?> memoryPerCall() / 1024 ), 2 ) ?> - time() / $totalcount ), 2 ) ?> - memory() / $totalcount / 1024 ), 2 ) ?> + time() / self::$totalcount ), 2 ) ?> + memory() / self::$totalcount / 1024 ), 2 ) ?> children as $child ) { - $child->display( $indent + 2 ); + $child->display( $expand, $indent + 2 ); } } } @@ -163,18 +164,15 @@ class profile_point { } function callsPerRequest() { - global $totalcount; - return @( $this->count / $totalcount ); + return @( $this->count / self::$totalcount ); } function timePerRequest() { - global $totalcount; - return @( $this->time / $totalcount ); + return @( $this->time / self::$totalcount ); } function memoryPerRequest() { - global $totalcount; - return @( $this->memory / $totalcount ); + return @( $this->memory / self::$totalcount ); } function fmttime() { @@ -244,9 +242,9 @@ else kb/req pf_name, $o->pf_count, $o->pf_time, $o->pf_memory ); if( $next->name() == '-total' ) { - $totaltime = $next->time(); - $totalcount = $next->count(); - $totalmemory = $next->memory(); + profile_point::$totaltime = $next->time(); + profile_point::$totalcount = $next->count(); + profile_point::$totalmemory = $next->memory(); } if ( $last !== false ) { if ( preg_match( "/^".preg_quote( $last->name(), "/" )."/", $next->name() ) ) { @@ -302,12 +300,12 @@ foreach ( $points as $point ) { if ( strlen( $filter ) && !strstr( $point->name(), $filter ) ) continue; - $point->display(); + $point->display( $expand ); } ?> -

Total time:

-

Total memory:

+

Total time:

+

Total memory: