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;
}
</style>
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();
}
}
function display($indent = 0.0) {
- global $expand, $totaltime, $totalcount;
+ global $expand, $totaltime, $totalmemory, $totalcount;
usort($this->children, "compare_point");
$extet = '';
}
?>
<tr>
- <td class="time"><tt><?php echo $this->fmttime() ?></tt></td>
- <td class="timep"><?php echo wfPercent( $this->time() / $totaltime * 100 ) ?></td>
- <td class="count"><?php echo $this->count() ?></td>
- <td class="cpr"><?php echo round( sprintf( '%.2f',$this->count() / $totalcount ), 2 ) ?>
<td class="name" style="padding-left: <?php echo $indent ?>em">
<?php echo htmlspecialchars($this->name()) . $extet ?>
</td>
+ <td class="time"><tt><?php echo $this->fmttime() ?></tt></td>
+ <td class="timep"><?php echo @wfPercent( $this->time() / $totaltime * 100 ) ?></td>
+ <td class="memoryp"><?php echo @wfPercent( $this->memory() / $totalmemory * 100 ) ?></td>
+ <td class="count"><?php echo $this->count() ?></td>
+ <td class="cpr"><?php echo @round( sprintf( '%.2f', $this->count() / $totalcount ), 2 ) ?>
+ <td class="tpc"><?php echo @round( sprintf( '%.2f', $this->time() / $this->count() ), 2 ) ?>
+ <td class="mpr"><?php echo @round( sprintf( '%.2f' ,$this->memory() / $this->count() / 1048576 ), 2 ) ?>
</tr>
<?php
if ($ex)
function time() {
return $this->time;
}
+
+ function memory() {
+ return $this->memory;
+ }
function fmttime() {
return sprintf("%5.02f", $this->time);
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'];
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());
<table cellspacing="0">
<tr id="top">
-<th><a href="<?php echo makeurl(false, "time") ?>">Time</a></th>
+<th><a href="<?php echo makeurl(false, "name") ?>">Name</a></th>
+<th><a href="<?php echo makeurl(false, "time") ?>">Time (ms)</a></th>
<th>Time (%)</th>
+<th><a href="<?php echo makeurl(false, "memory") ?>">Memory (%)</a></th>
<th><a href="<?php echo makeurl(false, "count") ?>">Count</a></th>
-<th>Avg calls per request</th>
-<th><a href="<?php echo makeurl(false, "name") ?>">Name</a></th>
+<th>Calls/request</th>
+<th>ms/call</th>
+<th>kb/call</th>
</tr>
<?php
$totaltime = 0.0;
$totalcount = 0;
+$totalmemory = 0.0;
function makeurl($_filter = false, $_sort = false, $_expand = false) {
global $filter, $sort, $expand;
$last = false;
while (($o = mysql_fetch_object($res)) !== false) {
- $next = new profile_point($o->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())) {
}
}
-$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;