From 58beeaa183056256fdcd42faefe05d0242db9f88 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 29 May 2009 16:48:12 +0000 Subject: [PATCH] Tweaks to profileinfo.php: * whitespaces fixes * changed "
" to "" since "method" should be either "get" or "post" and the script's name was incorrect --- profileinfo.php | 108 ++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 53 deletions(-) diff --git a/profileinfo.php b/profileinfo.php index de0348031b..fcce6d71c6 100644 --- a/profileinfo.php +++ b/profileinfo.php @@ -65,14 +65,14 @@ require_once( './includes/WebStart.php' ); name = $name; $this->count = $count; $this->time = $time; @@ -89,35 +89,35 @@ class profile_point { $this->children = array(); } - function add_child($child) { + function add_child( $child ) { $this->children[] = $child; } function display($indent = 0.0) { global $expand, $totaltime, $totalmemory, $totalcount; - usort($this->children, "compare_point"); + usort( $this->children, 'compare_point' ); $extet = ''; - if (isset($expand[$this->name()])) + if ( isset( $expand[$this->name()] ) ) $ex = true; else $ex = false; - if (!$ex) { - if (count($this->children)) { - $url = makeurl(false, false, $expand + array($this->name() => true)); + if ( !$ex ) { + if ( count( $this->children ) ) { + $url = makeurl( false, false, $expand + array( $this->name() => true ) ); $extet = " [+]"; } else $extet = ''; } else { $e = array(); - foreach ($expand as $name => $ep) - if ($name != $this->name()) - $e += array($name => $ep); + foreach ( $expand as $name => $ep ) + if ( $name != $this->name() ) + $e += array( $name => $ep ); - $extet = " [–]"; + $extet = " [–]"; } ?> - name()) . $extet ?> + name() ) . $extet ?> time() / $totaltime * 100 ) ?> memory() / $totalmemory * 100 ) ?> @@ -129,9 +129,9 @@ class profile_point { memory() / $totalcount / 1024 ), 2 ) ?> children as $child) { - $child->display($indent + 2); + if ( $ex ) { + foreach ( $this->children as $child ) { + $child->display( $indent + 2 ); } } } @@ -153,38 +153,38 @@ class profile_point { } function timePerCall() { - return @($this->time / $this->count); + return @( $this->time / $this->count ); } function memoryPerCall() { - return @($this->memory / $this->count); + return @( $this->memory / $this->count ); } function callsPerRequest() { global $totalcount; - return @($this->count / $totalcount); + return @( $this->count / $totalcount ); } function timePerRequest() { global $totalcount; - return @($this->time / $totalcount); + return @( $this->time / $totalcount ); } function memoryPerRequest() { global $totalcount; - return @($this->memory / $totalcount); + return @( $this->memory / $totalcount ); } function fmttime() { - return sprintf("%5.02f", $this->time); + return sprintf( "%5.02f", $this->time ); } }; -function compare_point($a, $b) { +function compare_point( $a, $b ) { global $sort; - switch ($sort) { + switch ( $sort ) { case "name": - return strcmp($a->name(), $b->name()); + return strcmp( $a->name(), $b->name() ); case "time": return $a->time() > $b->time() ? -1 : 1; case "memory": @@ -204,21 +204,23 @@ function compare_point($a, $b) { } } -$sorts = array("time","memory","count","calls_per_req","name","time_per_call","memory_per_call","time_per_req","memory_per_req"); +$sorts = array( 'time', 'memory', 'count', 'calls_per_req', 'name', + 'time_per_call', 'memory_per_call', 'time_per_req', 'memory_per_req' ); $sort = 'time'; -if (isset($_REQUEST['sort']) && in_array($_REQUEST['sort'], $sorts)) +if ( isset( $_REQUEST['sort'] ) && in_array( $_REQUEST['sort'], $sorts ) ) $sort = $_REQUEST['sort']; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'profiling', '*', array(), 'profileinfo.php', array( 'ORDER BY' => 'pf_name ASC' ) ); -if (isset($_REQUEST['filter'])) +if (isset( $_REQUEST['filter'] ) ) $filter = $_REQUEST['filter']; -else $filter = ''; +else + $filter = ''; ?> - +

@@ -229,30 +231,30 @@ else $filter = ''; - - - - - - - - - + + + + + + + + +pf_name, $o->pf_count, $o->pf_time, $o->pf_memory); + $next = new profile_point( $o->pf_name, $o->pf_count, $o->pf_time, $o->pf_memory ); if( $next->name() == '-total' ) { $totaltime = $next->time(); $totalcount = $next->count(); $totalmemory = $next->memory(); } - if ($last !== false) { - if (preg_match("/^".preg_quote($last->name(), "/")."/", $next->name())) { + if ( $last !== false ) { + if ( preg_match( "/^".preg_quote( $last->name(), "/" )."/", $next->name() ) ) { $last->add_child($next); continue; } } $last = $next; - if (preg_match("/^query: /", $next->name()) || preg_match("/^query-m: /", $next->name())) { + if ( preg_match( "/^query: /", $next->name() ) || preg_match( "/^query-m: /", $next->name() ) ) { $sqltotal += $next->time(); $queries[] = $next; } else { @@ -283,15 +285,15 @@ foreach( $res as $o ) { } } -$s = new profile_point("SQL Queries", 0, $sqltotal, 0, 0); -foreach ($queries as $q) +$s = new profile_point( "SQL Queries", 0, $sqltotal, 0, 0 ); +foreach ( $queries as $q ) $s->add_child($q); $points[] = $s; -usort($points, "compare_point"); +usort( $points, "compare_point" ); -foreach ($points as $point) { - if (strlen($filter) && !strstr($point->name(), $filter)) +foreach ( $points as $point ) { + if ( strlen( $filter ) && !strstr( $point->name(), $filter ) ) continue; $point->display(); -- 2.20.1
">Name">Time (%)">Memory (%)">Count">Calls/req">ms/call">kb/call">ms/req">kb/reqNameTime (%)Memory (%)CountCalls/reqms/callkb/callms/reqkb/req