padding-right: 0.5em;
}
- td.time, td.count {
+ td.time, td.timep, td.count, td.cpr {
text-align: right;
}
</style>
$wgDBadminuser = $wgDBadminpassword = $wgDBserver = $wgDBname = $wgEnableProfileInfo = false;
-define("MEDIAWIKI", 1);
-if ( isset( $_REQUEST['GLOBALS'] ) ) {
- print $GLOBALS;
- echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
- die( -1 );
-}
-
-require_once("./includes/Defines.php");
-require_once("./LocalSettings.php");
+define( 'MW_NO_SETUP', 1 );
+require_once( './includes/WebStart.php' );
require_once("./AdminSettings.php");
+require_once( './includes/GlobalFunctions.php' );
if (!$wgEnableProfileInfo) {
- wfDie("disabled");
+ echo "disabled\n";
+ exit( 1 );
}
foreach (array("wgDBadminuser", "wgDBadminpassword", "wgDBserver", "wgDBname") as $var)
- if ($$var === false)
- wfDie("AdminSettings.php not correct");
+ if ($$var === false) {
+ echo "AdminSettings.php not correct\n";
+ exit( 1 );
+ }
+
$expand = array();
if (isset($_REQUEST['expand']))
}
function display($indent = 0.0) {
- global $expand;
+ global $expand, $totaltime, $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>
$sort = $_REQUEST['sort'];
$dbh = mysql_connect($wgDBserver, $wgDBadminuser, $wgDBadminpassword)
- or wfDie("mysql server failed: " . mysql_error());
-mysql_select_db($wgDBname, $dbh) or wfDie(mysql_error($dbh));
+ 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
FROM profiling
ORDER BY pf_name ASC
-", $dbh) or wfDie("query failed: " . mysql_error());
+", $dbh) or die("query failed: " . mysql_error());
if (isset($_REQUEST['filter']))
$filter = $_REQUEST['filter'];
<table cellspacing="0">
<tr id="top">
<th><a href="<?php echo makeurl(false, "time") ?>">Time</a></th>
+<th>Time (%)</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>
</tr>
<?php
$totaltime = 0.0;
+$totalcount = 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);
- $totaltime += $next->time();
+ if( $next->name() == '-total' ) {
+ $totaltime = $next->time();
+ $totalcount = $next->count();
+ }
if ($last !== false) {
if (preg_match("/^".preg_quote($last->name(), "/")."/", $next->name())) {
$last->add_child($next);