Skip to content

Commit

Permalink
Added configuration flags ($g_show_queries_count and $g_show_queries_…
Browse files Browse the repository at this point in the history
…list)

that track the executed queries and display their total count, unique queries
count, and the actual list of queries executed.

Some examples of query counts:
view_bug_page: 68 total, 24 unique.
view_bug_advanced_page: 66 total, 22 unique.
report_bug_advanged_page: 53 total, 34 unique.
report_bug_page: 26 total, 13 unique.
summary_page: 226 total, 214 unque.


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@1157 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
vboctor committed Jun 25, 2002
1 parent aa6a2a3 commit f67d998
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
12 changes: 9 additions & 3 deletions core_database_API.php
Expand Up @@ -5,11 +5,11 @@
# See the files README and LICENSE for details

# --------------------------------------------------------
# $Revision: 1.12 $
# $Revision: 1.13 $
# $Author: vboctor $
# $Date: 2002-06-20 14:48:18 $
# $Date: 2002-06-25 10:19:58 $
#
# $Id: core_database_API.php,v 1.12 2002-06-20 14:48:18 vboctor Exp $
# $Id: core_database_API.php,v 1.13 2002-06-25 10:19:58 vboctor Exp $
# --------------------------------------------------------

###########################################################################
Expand All @@ -19,6 +19,9 @@
# This in the general interface for all database calls.
# The actual SQL queries are found in the pages.
# Use this as a starting point to port to other databases

# An array in which all executed queries are stored. This is used for profiling
$g_queries_array = array();

# --------------------
# connect to database and select database
Expand Down Expand Up @@ -63,6 +66,9 @@ function db_pconnect($p_hostname, $p_username, $p_password, $p_database, $p_port
# --------------------
# execute query, requires connection to be opened,
function db_query( $p_query ) {
global $g_queries_array;

array_push ( $g_queries_array, $p_query );

$t_result = mysql_query( $p_query );

Expand Down
15 changes: 14 additions & 1 deletion core_html_API.php
Expand Up @@ -172,7 +172,8 @@ function print_footer( $p_file ) {
global $g_string_cookie_val, $g_webmaster_email,
$g_menu_include_file, $g_show_footer_menu,
$g_mantis_version, $g_show_version,
$g_timer, $g_show_timer;
$g_timer, $g_show_timer,
$g_show_queries_count, $g_show_queries_list, $g_queries_array;

# @@@
if (isset($g_string_cookie_val)&&!empty($g_string_cookie_val)) {
Expand All @@ -194,6 +195,18 @@ function print_footer( $p_file ) {
if ( ON == $g_show_timer ) {
$g_timer->print_times();
}
if ( ON == $g_show_queries_count ) {
$t_count = count( $g_queries_array );
PRINT "$t_count total queries executed.<br />";
PRINT count( array_unique ( $g_queries_array ) ) . " unique queries executed.<br />";
if ( ON == $g_show_queries_list ) {
PRINT '<table>';
for ( $i = 0; $i < $t_count; $i++ ) {
PRINT "<tr><td>". ($i+1) ."</td><td>$g_queries_array[$i]</td></tr>";
}
PRINT '</table>';
}
}
}
# --------------------
# (13) Ends the <BODY> section.
Expand Down
1 change: 1 addition & 0 deletions doc/ChangeLog
Expand Up @@ -72,6 +72,7 @@ Mantis ChangeLog
* Added multiple bug actions in view_all_bug_page.php.
* Added a direct link, with a small icon, on each bug row, so that users on a selected project can switch directly to the bug_update_advanced_page.
* Added automatic defaults for $g_path and $g_absolute_path rather than dummy values. This should avoid the need of redefining these values in custom_config_inc.php and also support multiple domains.
* Added configuration flags ($g_show_queries_count and $g_show_queries_list) that track the executed queries and display their total count, unique queries count, and the actual list of queries executed.

2002.05.19 - 0.17.3

Expand Down

0 comments on commit f67d998

Please sign in to comment.