2008-09-23 18:23:09 +00:00
|
|
|
|
<?php
|
2010-08-07 14:35:18 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Show profiling data.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Copyright 2005 Kate Turner.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
|
*
|
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
|
|
*
|
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
|
*
|
|
|
|
|
|
* @file
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2016-05-05 15:35:10 +00:00
|
|
|
|
// This endpoint is supposed to be independent of request cookies and other
|
|
|
|
|
|
// details of the session. Log warnings for violations of the no-session
|
|
|
|
|
|
// constraint.
|
|
|
|
|
|
define( 'MW_NO_SESSION', 'warn' );
|
|
|
|
|
|
|
2008-09-23 18:23:09 +00:00
|
|
|
|
ini_set( 'zlib.output_compression', 'off' );
|
|
|
|
|
|
|
2014-12-03 18:36:12 +00:00
|
|
|
|
$wgEnableProfileInfo = false;
|
2013-05-17 00:16:59 +00:00
|
|
|
|
require __DIR__ . '/includes/WebStart.php';
|
2008-09-23 18:23:09 +00:00
|
|
|
|
|
2011-02-11 19:28:04 +00:00
|
|
|
|
header( 'Content-Type: text/html; charset=utf-8' );
|
|
|
|
|
|
|
2008-09-23 18:23:09 +00:00
|
|
|
|
?>
|
2012-09-26 20:55:54 +00:00
|
|
|
|
<!DOCTYPE html>
|
2005-07-03 02:22:09 +00:00
|
|
|
|
<html>
|
|
|
|
|
|
<head>
|
2015-02-09 12:04:05 +00:00
|
|
|
|
<meta charset="UTF-8" />
|
2013-02-13 18:38:32 +00:00
|
|
|
|
<title>Profiling data</title>
|
|
|
|
|
|
<style>
|
|
|
|
|
|
/* noc.wikimedia.org/base.css */
|
|
|
|
|
|
|
|
|
|
|
|
* {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
padding: 0;
|
|
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
body {
|
|
|
|
|
|
padding: 0.5em 1em;
|
|
|
|
|
|
background: #fff;
|
|
|
|
|
|
font: 14px/1.6 sans-serif;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
p, ul, ol, table {
|
|
|
|
|
|
margin: 0.5em 0;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
a {
|
|
|
|
|
|
color: #0645AD;
|
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
a:hover {
|
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
/*!
|
|
|
|
|
|
* Bootstrap v2.1.1
|
|
|
|
|
|
*
|
|
|
|
|
|
* Copyright 2012 Twitter, Inc
|
|
|
|
|
|
* Licensed under the Apache License v2.0
|
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
*
|
|
|
|
|
|
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
table {
|
|
|
|
|
|
max-width: 100%;
|
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
|
border-collapse: collapse;
|
|
|
|
|
|
border-spacing: 0;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
}
|
2012-03-23 07:31:46 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table th,
|
|
|
|
|
|
.table td {
|
|
|
|
|
|
padding: 0.1em;
|
|
|
|
|
|
text-align: left;
|
|
|
|
|
|
vertical-align: top;
|
|
|
|
|
|
border-top: 1px solid #ddd;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table th {
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table thead th {
|
|
|
|
|
|
vertical-align: bottom;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table thead:first-child tr:first-child th,
|
|
|
|
|
|
.table thead:first-child tr:first-child td {
|
|
|
|
|
|
border-top: 0;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table tbody + tbody {
|
|
|
|
|
|
border-top: 2px solid #ddd;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table-condensed th,
|
|
|
|
|
|
.table-condensed td {
|
|
|
|
|
|
padding: 4px 5px;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table-striped tbody tr:nth-child(odd) td,
|
|
|
|
|
|
.table-striped tbody tr:nth-child(odd) th {
|
|
|
|
|
|
background-color: #f9f9f9;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
.table-hover tbody tr:hover td,
|
|
|
|
|
|
.table-hover tbody tr:hover th {
|
|
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
hr {
|
|
|
|
|
|
margin: 20px 0;
|
|
|
|
|
|
border: 0;
|
|
|
|
|
|
border-top: 1px solid #eee;
|
|
|
|
|
|
border-bottom: 1px solid #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
2005-07-03 02:22:09 +00:00
|
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
2009-05-29 16:48:12 +00:00
|
|
|
|
if ( !$wgEnableProfileInfo ) {
|
2012-09-26 20:55:54 +00:00
|
|
|
|
echo '<p>Disabled</p>'
|
|
|
|
|
|
. '</body></html>';
|
2006-10-04 07:14:56 +00:00
|
|
|
|
exit( 1 );
|
2006-01-14 02:49:43 +00:00
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2011-09-08 14:53:07 +00:00
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
if ( !$dbr->tableExists( 'profiling' ) ) {
|
2012-09-26 20:55:54 +00:00
|
|
|
|
echo '<p>No <code>profiling</code> table exists, so we can\'t show you anything.</p>'
|
2014-12-03 18:36:12 +00:00
|
|
|
|
. '<p>If you want to log profiling data, enable <code>$wgProfiler[\'output\'] = \'db\'</code>'
|
|
|
|
|
|
. ' in your StartProfiler.php and run <code>maintenance/update.php</code> to'
|
2012-10-07 12:15:57 +00:00
|
|
|
|
. ' create the profiling table.'
|
2012-09-26 20:55:54 +00:00
|
|
|
|
. '</body></html>';
|
2011-09-08 14:53:07 +00:00
|
|
|
|
exit( 1 );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$expand = [];
|
2013-02-13 18:38:32 +00:00
|
|
|
|
if ( isset( $_REQUEST['expand'] ) ) {
|
|
|
|
|
|
foreach ( explode( ',', $_REQUEST['expand'] ) as $f ) {
|
2005-07-03 02:22:09 +00:00
|
|
|
|
$expand[$f] = true;
|
2013-02-13 18:38:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreStart
|
2005-07-03 02:22:09 +00:00
|
|
|
|
class profile_point {
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreEnd
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public $name;
|
|
|
|
|
|
public $count;
|
|
|
|
|
|
public $time;
|
|
|
|
|
|
public $children;
|
2010-09-29 16:05:46 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public static $totaltime, $totalmemory, $totalcount;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct( $name, $count, $time, $memory ) {
|
2005-07-03 02:22:09 +00:00
|
|
|
|
$this->name = $name;
|
|
|
|
|
|
$this->count = $count;
|
|
|
|
|
|
$this->time = $time;
|
2008-04-29 12:10:56 +00:00
|
|
|
|
$this->memory = $memory;
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$this->children = [];
|
2005-07-03 02:22:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function add_child( $child ) {
|
2005-07-03 02:22:09 +00:00
|
|
|
|
$this->children[] = $child;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function display( $expand, $indent = 0.0 ) {
|
2009-05-29 16:48:12 +00:00
|
|
|
|
usort( $this->children, 'compare_point' );
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2010-10-14 20:53:04 +00:00
|
|
|
|
$ex = isset( $expand[$this->name()] );
|
|
|
|
|
|
|
2012-11-19 14:34:34 +00:00
|
|
|
|
$anchor = str_replace( '"', '', $this->name() );
|
|
|
|
|
|
|
2009-05-29 16:48:12 +00:00
|
|
|
|
if ( !$ex ) {
|
|
|
|
|
|
if ( count( $this->children ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$url = getEscapedProfileUrl( false, false, $expand + [ $this->name() => true ] );
|
2012-11-19 14:34:34 +00:00
|
|
|
|
$extet = " <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[+]</a>";
|
2010-10-14 20:53:04 +00:00
|
|
|
|
} else {
|
|
|
|
|
|
$extet = '';
|
|
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
} else {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$e = [];
|
2010-10-14 20:53:04 +00:00
|
|
|
|
foreach ( $expand as $name => $ep ) {
|
|
|
|
|
|
if ( $name != $this->name() ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$e += [ $name => $ep ];
|
2010-10-14 20:53:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2012-11-19 14:34:34 +00:00
|
|
|
|
$url = getEscapedProfileUrl( false, false, $e );
|
|
|
|
|
|
$extet = " <a id=\"{$anchor}\" href=\"{$url}#{$anchor}\">[–]</a>";
|
2005-07-03 02:22:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
?>
|
2013-02-13 18:38:32 +00:00
|
|
|
|
<tr>
|
|
|
|
|
|
<th>
|
|
|
|
|
|
<div style="margin-left: <?php echo (int)$indent; ?>em;">
|
|
|
|
|
|
<?php echo htmlspecialchars( str_replace( ',', ', ', $this->name() ) ) . $extet ?>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</th>
|
2014-08-11 21:32:04 +00:00
|
|
|
|
<?php //@codingStandardsIgnoreStart ?>
|
2012-09-26 20:55:54 +00:00
|
|
|
|
<td class="mw-profileinfo-timep"><?php echo @wfPercent( $this->time() / self::$totaltime * 100 ); ?></td>
|
|
|
|
|
|
<td class="mw-profileinfo-memoryp"><?php echo @wfPercent( $this->memory() / self::$totalmemory * 100 ); ?></td>
|
|
|
|
|
|
<td class="mw-profileinfo-count"><?php echo $this->count(); ?></td>
|
|
|
|
|
|
<td class="mw-profileinfo-cpr"><?php echo round( sprintf( '%.2f', $this->callsPerRequest() ), 2 ); ?></td>
|
|
|
|
|
|
<td class="mw-profileinfo-tpc"><?php echo round( sprintf( '%.2f', $this->timePerCall() ), 2 ); ?></td>
|
2013-01-30 14:03:58 +00:00
|
|
|
|
<td class="mw-profileinfo-mpc"><?php echo round( sprintf( '%.2f', $this->memoryPerCall() / 1024 ), 2 ); ?></td>
|
2012-09-26 20:55:54 +00:00
|
|
|
|
<td class="mw-profileinfo-tpr"><?php echo @round( sprintf( '%.2f', $this->time() / self::$totalcount ), 2 ); ?></td>
|
2013-01-30 14:03:58 +00:00
|
|
|
|
<td class="mw-profileinfo-mpr"><?php echo @round( sprintf( '%.2f', $this->memory() / self::$totalcount / 1024 ), 2 ); ?></td>
|
2014-08-11 21:32:04 +00:00
|
|
|
|
<?php //@codingStandardsIgnoreEnd ?>
|
2013-02-13 18:38:32 +00:00
|
|
|
|
</tr>
|
2005-07-03 02:22:09 +00:00
|
|
|
|
<?php
|
2009-05-29 16:48:12 +00:00
|
|
|
|
if ( $ex ) {
|
|
|
|
|
|
foreach ( $this->children as $child ) {
|
2010-09-29 16:05:46 +00:00
|
|
|
|
$child->display( $expand, $indent + 2 );
|
2008-04-29 16:50:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function name() {
|
2005-07-03 02:22:09 +00:00
|
|
|
|
return $this->name;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function count() {
|
2005-07-03 02:22:09 +00:00
|
|
|
|
return $this->count;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function time() {
|
2005-07-03 02:22:09 +00:00
|
|
|
|
return $this->time;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function memory() {
|
2008-04-29 12:10:56 +00:00
|
|
|
|
return $this->memory;
|
|
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function timePerCall() {
|
|
|
|
|
|
// @codingStandardsIgnoreStart
|
2009-05-29 16:48:12 +00:00
|
|
|
|
return @( $this->time / $this->count );
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreEnd
|
2008-04-29 15:03:21 +00:00
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function memoryPerCall() {
|
|
|
|
|
|
// @codingStandardsIgnoreStart
|
2009-05-29 16:48:12 +00:00
|
|
|
|
return @( $this->memory / $this->count );
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreEnd
|
2008-04-29 15:03:21 +00:00
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function callsPerRequest() {
|
|
|
|
|
|
// @codingStandardsIgnoreStart
|
2010-09-29 16:05:46 +00:00
|
|
|
|
return @( $this->count / self::$totalcount );
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreEnd
|
2008-04-29 15:03:21 +00:00
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function timePerRequest() {
|
|
|
|
|
|
// @codingStandardsIgnoreStart
|
2010-09-29 16:05:46 +00:00
|
|
|
|
return @( $this->time / self::$totalcount );
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreEnd
|
2008-04-29 15:03:21 +00:00
|
|
|
|
}
|
2012-09-26 20:55:54 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function memoryPerRequest() {
|
|
|
|
|
|
// @codingStandardsIgnoreStart
|
2010-09-29 16:05:46 +00:00
|
|
|
|
return @( $this->memory / self::$totalcount );
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreEnd
|
2008-04-29 15:03:21 +00:00
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2014-08-11 21:32:04 +00:00
|
|
|
|
public function fmttime() {
|
2012-09-26 20:55:54 +00:00
|
|
|
|
return sprintf( '%5.02f', $this->time );
|
2005-07-03 02:22:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
function compare_point( profile_point $a, profile_point $b ) {
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreStart
|
2005-07-03 02:22:09 +00:00
|
|
|
|
global $sort;
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreEnd
|
2009-05-29 16:48:12 +00:00
|
|
|
|
switch ( $sort ) {
|
2013-02-13 18:38:32 +00:00
|
|
|
|
case 'name':
|
|
|
|
|
|
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;
|
|
|
|
|
|
case 'time_per_call':
|
|
|
|
|
|
return $a->timePerCall() > $b->timePerCall() ? -1 : 1;
|
|
|
|
|
|
case 'memory_per_call':
|
|
|
|
|
|
return $a->memoryPerCall() > $b->memoryPerCall() ? -1 : 1;
|
|
|
|
|
|
case 'calls_per_req':
|
|
|
|
|
|
return $a->callsPerRequest() > $b->callsPerRequest() ? -1 : 1;
|
|
|
|
|
|
case 'time_per_req':
|
|
|
|
|
|
return $a->timePerRequest() > $b->timePerRequest() ? -1 : 1;
|
|
|
|
|
|
case 'memory_per_req':
|
|
|
|
|
|
return $a->memoryPerRequest() > $b->memoryPerRequest() ? -1 : 1;
|
2005-07-03 02:22:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$sorts = [ 'time', 'memory', 'count', 'calls_per_req', 'name',
|
|
|
|
|
|
'time_per_call', 'memory_per_call', 'time_per_req', 'memory_per_req' ];
|
2005-07-03 02:22:09 +00:00
|
|
|
|
$sort = 'time';
|
2013-02-13 18:38:32 +00:00
|
|
|
|
if ( isset( $_REQUEST['sort'] ) && in_array( $_REQUEST['sort'], $sorts ) ) {
|
2005-07-03 02:22:09 +00:00
|
|
|
|
$sort = $_REQUEST['sort'];
|
2013-02-13 18:38:32 +00:00
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2015-09-27 07:51:29 +00:00
|
|
|
|
$res = $dbr->select(
|
|
|
|
|
|
'profiling',
|
|
|
|
|
|
'*',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
[],
|
2015-09-27 07:51:29 +00:00
|
|
|
|
'profileinfo.php',
|
2016-02-17 09:09:32 +00:00
|
|
|
|
[ 'ORDER BY' => 'pf_name ASC' ]
|
2015-09-27 07:51:29 +00:00
|
|
|
|
);
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
if ( isset( $_REQUEST['filter'] ) ) {
|
2005-07-03 02:22:09 +00:00
|
|
|
|
$filter = $_REQUEST['filter'];
|
2013-02-13 18:38:32 +00:00
|
|
|
|
} else {
|
2009-05-29 16:48:12 +00:00
|
|
|
|
$filter = '';
|
2013-02-13 18:38:32 +00:00
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
|
|
|
|
|
?>
|
2009-05-29 16:48:12 +00:00
|
|
|
|
<form method="get" action="profileinfo.php">
|
2013-02-13 18:38:32 +00:00
|
|
|
|
<p>
|
|
|
|
|
|
<input type="text" name="filter" value="<?php echo htmlspecialchars( $filter ); ?>">
|
|
|
|
|
|
<input type="hidden" name="sort" value="<?php echo htmlspecialchars( $sort ); ?>">
|
2015-09-27 07:51:29 +00:00
|
|
|
|
<input type="hidden" name="expand" value="<?php
|
|
|
|
|
|
echo htmlspecialchars( implode( ",", array_keys( $expand ) ) );
|
|
|
|
|
|
?>">
|
2013-02-13 18:38:32 +00:00
|
|
|
|
<input type="submit" value="Filter">
|
|
|
|
|
|
</p>
|
2005-07-03 02:22:09 +00:00
|
|
|
|
</form>
|
|
|
|
|
|
|
2012-09-26 20:55:54 +00:00
|
|
|
|
<table class="mw-profileinfo-table table table-striped table-hover">
|
|
|
|
|
|
<thead>
|
2013-02-13 18:38:32 +00:00
|
|
|
|
<tr>
|
2015-09-27 07:51:29 +00:00
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'name' );
|
|
|
|
|
|
?>">Name</a></th>
|
|
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'time' );
|
|
|
|
|
|
?>">Time (%)</a></th>
|
|
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'memory' );
|
|
|
|
|
|
?>">Memory (%)</a></th>
|
|
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'count' );
|
|
|
|
|
|
?>">Count</a></th>
|
|
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'calls_per_req' );
|
|
|
|
|
|
?>">Calls/req</a></th>
|
|
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'time_per_call' );
|
|
|
|
|
|
?>">ms/call</a></th>
|
|
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'memory_per_call' );
|
|
|
|
|
|
?>">kb/call</a></th>
|
|
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'time_per_req' );
|
|
|
|
|
|
?>">ms/req</a></th>
|
|
|
|
|
|
<th><a href="<?php
|
|
|
|
|
|
echo getEscapedProfileUrl( false, 'memory_per_req' );
|
|
|
|
|
|
?>">kb/req</a></th>
|
2013-02-13 18:38:32 +00:00
|
|
|
|
</tr>
|
2012-09-26 20:55:54 +00:00
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
2013-02-13 18:38:32 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
profile_point::$totaltime = 0.0;
|
|
|
|
|
|
profile_point::$totalcount = 0;
|
|
|
|
|
|
profile_point::$totalmemory = 0.0;
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
function getEscapedProfileUrl( $_filter = false, $_sort = false, $_expand = false ) {
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreStart
|
2013-02-13 18:38:32 +00:00
|
|
|
|
global $filter, $sort, $expand;
|
2014-08-11 21:32:04 +00:00
|
|
|
|
// @codingStandardsIgnoreEnd
|
2013-02-13 18:38:32 +00:00
|
|
|
|
|
|
|
|
|
|
if ( $_expand === false ) {
|
|
|
|
|
|
$_expand = $expand;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return htmlspecialchars(
|
|
|
|
|
|
'?' .
|
2016-02-17 09:09:32 +00:00
|
|
|
|
wfArrayToCgi( [
|
2013-02-13 18:38:32 +00:00
|
|
|
|
'filter' => $_filter ? $_filter : $filter,
|
|
|
|
|
|
'sort' => $_sort ? $_sort : $sort,
|
|
|
|
|
|
'expand' => implode( ',', array_keys( $_expand ) )
|
2016-02-17 09:09:32 +00:00
|
|
|
|
] )
|
2013-02-13 18:38:32 +00:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
|
$points = [];
|
|
|
|
|
|
$queries = [];
|
2013-02-13 18:38:32 +00:00
|
|
|
|
$sqltotal = 0.0;
|
|
|
|
|
|
|
|
|
|
|
|
$last = false;
|
|
|
|
|
|
foreach ( $res as $o ) {
|
|
|
|
|
|
$next = new profile_point( $o->pf_name, $o->pf_count, $o->pf_time, $o->pf_memory );
|
2014-11-14 18:58:07 +00:00
|
|
|
|
if ( $next->name() == '-total' || $next->name() == 'main()' ) {
|
2013-02-13 18:38:32 +00:00
|
|
|
|
profile_point::$totaltime = $next->time();
|
|
|
|
|
|
profile_point::$totalcount = $next->count();
|
|
|
|
|
|
profile_point::$totalmemory = $next->memory();
|
|
|
|
|
|
}
|
|
|
|
|
|
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() ) ) {
|
|
|
|
|
|
$sqltotal += $next->time();
|
|
|
|
|
|
$queries[] = $next;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$points[] = $next;
|
2005-07-03 02:22:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
$s = new profile_point( 'SQL Queries', 0, $sqltotal, 0, 0 );
|
2013-05-09 17:48:10 +00:00
|
|
|
|
foreach ( $queries as $q ) {
|
2013-02-13 18:38:32 +00:00
|
|
|
|
$s->add_child( $q );
|
2013-05-09 17:48:10 +00:00
|
|
|
|
}
|
2013-02-13 18:38:32 +00:00
|
|
|
|
$points[] = $s;
|
2005-07-03 02:36:51 +00:00
|
|
|
|
|
2015-11-18 01:24:20 +00:00
|
|
|
|
// @codingStandardsIgnoreStart
|
|
|
|
|
|
@usort( $points, 'compare_point' );
|
|
|
|
|
|
// @codingStandardsIgnoreEnd
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
foreach ( $points as $point ) {
|
|
|
|
|
|
if ( strlen( $filter ) && !strstr( $point->name(), $filter ) ) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2005-07-03 02:22:09 +00:00
|
|
|
|
|
2013-02-13 18:38:32 +00:00
|
|
|
|
$point->display( $expand );
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|
2012-09-26 20:55:54 +00:00
|
|
|
|
</tbody>
|
2005-07-03 02:22:09 +00:00
|
|
|
|
</table>
|
2015-02-09 12:04:05 +00:00
|
|
|
|
<hr />
|
2013-02-13 18:38:32 +00:00
|
|
|
|
<p>Total time: <code><?php printf( '%5.02f', profile_point::$totaltime ); ?></code></p>
|
|
|
|
|
|
|
|
|
|
|
|
<p>Total memory: <code><?php printf( '%5.02f', profile_point::$totalmemory / 1024 ); ?></code></p>
|
|
|
|
|
|
<hr />
|
2005-07-03 02:22:09 +00:00
|
|
|
|
</body>
|
2005-07-06 05:18:09 +00:00
|
|
|
|
</html>
|