+<?php
+ini_set( 'zlib.output_compression', 'off' );
+
+$wgEnableProfileInfo = $wgProfileToDatabase = false;
+
+require_once( './includes/WebStart.php' );
+@include_once( './AdminSettings.php' );
+
+?>
<!--
Show profiling data.
<body>
<?php
-$wgDBadminuser = $wgDBadminpassword = $wgDBserver = $wgDBname = $wgEnableProfileInfo = $wgDBprefix = false;
-
-define( 'MW_NO_SETUP', 1 );
-require_once( './includes/WebStart.php' );
-require_once("./AdminSettings.php");
-require_once( './includes/GlobalFunctions.php' );
-
if (!$wgEnableProfileInfo) {
echo "disabled\n";
exit( 1 );
}
-foreach (array("wgDBadminuser", "wgDBadminpassword", "wgDBserver", "wgDBname") as $var)
- if ($$var === false) {
- echo "AdminSettings.php not correct\n";
- exit( 1 );
- }
-
-
$expand = array();
if (isset($_REQUEST['expand']))
foreach(explode(",", $_REQUEST['expand']) as $f)
}
?>
<tr>
- <td class="name" style="padding-left: <?php echo $indent ?>em">
+ <td class="name" style="padding-left: <?php echo $indent ?>em;">
<?php echo htmlspecialchars($this->name()) . $extet ?>
</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="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->callsPerRequest() ), 2 ) ?></td>
<td class="tpc"><?php echo round( sprintf( '%.2f', $this->timePerCall() ), 2 ) ?></td>
- <td class="mpc"><?php echo round( sprintf( '%.2f' ,$this->memoryPerCall() / 1048576 ), 2 ) ?></td>
- <td class="tpr"><?php echo round( sprintf( '%.2f', $this->time() / $totalcount ), 2 ) ?></td>
- <td class="mpr"><?php echo round( sprintf( '%.2f' ,$this->memory() / $totalcount / 1048576 ), 2 ) ?></td>
+ <td class="mpc"><?php echo round( sprintf( '%.2f' ,$this->memoryPerCall() / 1024 ), 2 ) ?></td>
+ <td class="tpr"><?php echo @round( sprintf( '%.2f', $this->time() / $totalcount ), 2 ) ?></td>
+ <td class="mpr"><?php echo @round( sprintf( '%.2f' ,$this->memory() / $totalcount / 1024 ), 2 ) ?></td>
</tr>
<?php
- if ($ex)
- foreach ($this->children as $child)
+ if ($ex) {
+ foreach ($this->children as $child) {
$child->display($indent + 2);
+ }
+ }
}
function name() {
if (isset($_REQUEST['sort']) && in_array($_REQUEST['sort'], $sorts))
$sort = $_REQUEST['sort'];
-$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_memory, pf_name
- FROM {$wgDBprefix}profiling
- ORDER BY pf_name ASC
-", $dbh) or die("query failed: " . mysql_error());
+
+$dbr = wfGetDB( DB_SLAVE );
+$res = $dbr->select( 'profiling', '*', array(), 'profileinfo.php', array( 'ORDER BY' => 'pf_name ASC' ) );
if (isset($_REQUEST['filter']))
$filter = $_REQUEST['filter'];
</p>
</form>
-<table cellspacing="0">
+<table cellspacing="0" border="1">
<tr id="top">
<th><a href="<?php echo makeurl(false, "name") ?>">Name</a></th>
<th><a href="<?php echo makeurl(false, "time") ?>">Time (%)</a></th>
<th><a href="<?php echo makeurl(false, "memory") ?>">Memory (%)</a></th>
<th><a href="<?php echo makeurl(false, "count") ?>">Count</a></th>
-<th><a href="<?php echo makeurl(false, "calls_per_req") ?>">Calls/request</a></th>
+<th><a href="<?php echo makeurl(false, "calls_per_req") ?>">Calls/req</a></th>
<th><a href="<?php echo makeurl(false, "time_per_call") ?>">ms/call</a></th>
<th><a href="<?php echo makeurl(false, "memory_per_call") ?>">kb/call</a></th>
-<th><a href="<?php echo makeurl(false, "time_per_req") ?>">ms/request</a></th>
-<th><a href="<?php echo makeurl(false, "memory_per_req") ?>">kb/request</a></th>
+<th><a href="<?php echo makeurl(false, "time_per_req") ?>">ms/req</a></th>
+<th><a href="<?php echo makeurl(false, "memory_per_req") ?>">kb/req</a></th>
</tr>
<?php
$totaltime = 0.0;
$sqltotal = 0.0;
$last = false;
-while (($o = mysql_fetch_object($res)) !== false) {
+foreach( $res as $o ) {
$next = new profile_point($o->pf_name, $o->pf_count, $o->pf_time, $o->pf_memory);
if( $next->name() == '-total' ) {
$totaltime = $next->time();
}
}
$last = $next;
- if (preg_match("/^query: /", $next->name())) {
+ if (preg_match("/^query: /", $next->name()) || preg_match("/^query-m: /", $next->name())) {
$sqltotal += $next->time();
$queries[] = $next;
} else {
</table>
<p>Total time: <tt><?php printf("%5.02f", $totaltime) ?></tt></p>
-<p>Total memory: <tt><?php printf("%5.02f", $totalmemory / 1048576 ) ?></tt></p>
+<p>Total memory: <tt><?php printf("%5.02f", $totalmemory / 1024 ) ?></tt></p>
<?php
-mysql_free_result($res);
-mysql_close($dbh);
+$res->free();
?>
</body>