From 1a4afa8f7ed947d6a0482c2cd7d6af5a52a3063d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 29 Apr 2008 12:10:56 +0000 Subject: [PATCH] Re-arrange a little. Show memory. --- profileinfo.php | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/profileinfo.php b/profileinfo.php index b748609142..15b292ac27 100644 --- a/profileinfo.php +++ b/profileinfo.php @@ -36,7 +36,7 @@ padding-right: 0.5em; } - td.time, td.timep, td.count, td.cpr { + td.time, td.timep, td.memory, td.memoryp, td.count, td.cpr { text-align: right; } @@ -74,10 +74,11 @@ class profile_point { var $time; var $children; - function profile_point($name, $count, $time) { + function profile_point($name, $count, $time, $memory ) { $this->name = $name; $this->count = $count; $this->time = $time; + $this->memory = $memory; $this->children = array(); } @@ -86,7 +87,7 @@ class profile_point { } function display($indent = 0.0) { - global $expand, $totaltime, $totalcount; + global $expand, $totaltime, $totalmemory, $totalcount; usort($this->children, "compare_point"); $extet = ''; @@ -108,13 +109,16 @@ class profile_point { } ?> - fmttime() ?> - time() / $totaltime * 100 ) ?> - count() ?> - count() / $totalcount ), 2 ) ?> name()) . $extet ?> + fmttime() ?> + time() / $totaltime * 100 ) ?> + memory() / $totalmemory * 100 ) ?> + count() ?> + count() / $totalcount ), 2 ) ?> + time() / $this->count() ), 2 ) ?> + memory() / $this->count() / 1048576 ), 2 ) ?> time; } + + function memory() { + return $this->memory; + } function fmttime() { return sprintf("%5.02f", $this->time); @@ -146,12 +154,14 @@ function compare_point($a, $b) { return strcmp($a->name(), $b->name()); case "time": return $a->time() > $b->time() ? -1 : 1; + case "memory": + return $a->memory() > $b->memory() ? -1 : 1; case "count": return $a->count() > $b->count() ? -1 : 1; } } -$sorts = array("time", "count", "name"); +$sorts = array("time", "memory", "count", "name"); $sort = 'time'; if (isset($_REQUEST['sort']) && in_array($_REQUEST['sort'], $sorts)) $sort = $_REQUEST['sort']; @@ -160,7 +170,7 @@ $dbh = mysql_connect($wgDBserver, $wgDBadminuser, $wgDBadminpassword) or die("mysql server failed: " . mysql_error()); mysql_select_db($wgDBname, $dbh) or die(mysql_error($dbh)); $res = mysql_query(" - SELECT pf_count, pf_time, pf_name + SELECT pf_count, pf_time, pf_memory, pf_name FROM {$wgDBprefix}profiling ORDER BY pf_name ASC ", $dbh) or die("query failed: " . mysql_error()); @@ -181,15 +191,19 @@ else $filter = ''; - + + + - - + + +pf_name, $o->pf_count, $o->pf_time); + $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())) { @@ -229,7 +244,7 @@ while (($o = mysql_fetch_object($res)) !== false) { } } -$s = new profile_point("SQL Queries", 0, $sqltotal); +$s = new profile_point("SQL Queries", 0, $sqltotal, 0, 0); foreach ($queries as $q) $s->add_child($q); $points[] = $s; -- 2.20.1
">Time">Name">Time (ms) Time (%)">Memory (%) ">CountAvg calls per request">NameCalls/requestms/callkb/call