View Issue Details

IDProjectCategoryView StatusLast Update
0004348mantisbtperformancepublic2004-08-29 01:27
ReporterDGtlRift Assigned Tothraxisp  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Product Version0.19.0a2 
Fixed in Version0.19.0rc1 
Summary0004348: Show queries with runtime
Description

For debugging purposes, it would help with development if when g_show_queries_list is on, in addition to printing all the queries executed, it would also show the time taken for each query (cached or new).

TagsNo tags attached.

Activities

DGtlRift

DGtlRift

2004-08-18 07:32

reporter   ~0007049

This is related to issue 0004345

vboctor

vboctor

2004-08-18 07:59

manager   ~0007052

Sounds good. If someone provides a patch it will be added to CVS.

grangeway

grangeway

2004-08-21 11:43

reporter   ~0007097

===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/database_api.php,v
retrieving revision 1.30
diff -u -r1.30 database_api.php
--- database_api.php 29 Jun 2004 14:08:28 -0000 1.30
+++ database_api.php 21 Aug 2004 16:09:52 -0000
@@ -88,13 +88,16 @@
function db_query( $p_query, $p_limit = -1, $p_offset = -1 ) {
global $g_queries_array, $g_db;

  • array_push ( $g_queries_array, $p_query );
  • $t_start = microtime();
  • if ( ( $p_limit != -1 ) || ( $p_offset != -1 ) ) {
        $t_result = $g_db->SelectLimit( $p_query, $p_limit, $p_offset );
    } else {
        $t_result = $g_db->Execute( $p_query );
    }
  • $t_elapsed = number_format(microtime() - $t_start,4);
  • array_push ( $g_queries_array, array( $p_query, $t_elapsed ) );

    if ( !$t_result ) {
        db_error($p_query);

    Index: html_api.php

    RCS file: /cvsroot/mantisbt/mantisbt/core/html_api.php,v
    retrieving revision 1.124
    diff -u -r1.124 html_api.php
    --- html_api.php 20 Aug 2004 17:27:28 -0000 1.124
    +++ html_api.php 21 Aug 2004 16:44:22 -0000
    @@ -339,14 +339,19 @@
    if ( ON == config_get( 'show_queries_list' ) ) {
    echo "\t", '<table>', "\n";
    $t_shown_queries = array();

  • $t_total = 0;
    for ( $i = 0; $i < $t_count; $i++ ) {
  • $t_time = $g_queries_array[$i][1];
  • $t_total += $t_time;
    if ( in_array( $g_queries_array[$i], $t_shown_queries ) ) {
  • echo "\t", '<tr><td style="color: red">', ($i+1), '</td><td style="color: red">', htmlspecialchars($g_queries_array[$i]), '</td></tr>', "\n";
  • echo "\t", '<tr><td style="color: red">', ($i+1), '</td><td style="color: red">', $t_time, '</td><td style="color: red">', htmlspecialchars($g_queries_array[$i]), '</td></tr>', "\n";
    } else {
    array_push( $t_shown_queries, $g_queries_array[$i] );
  • echo "\t", '<tr><td>', ($i+1), '</td><td>', htmlspecialchars($g_queries_array[$i]), '</td></tr>', "\n";
  • echo "\t", '<tr><td>', ($i+1), '</td><td>', $t_time, '</td><td>', htmlspecialchars($g_queries_array[$i][0]), '</td></tr>', "\n";
    }
  •         }
  • echo "\t", '<tr><td></td><td>', $t_total, '</td><td></td></tr>', "\n";
    echo "\t", '</table>', "\n";
    }
    }
grangeway

grangeway

2004-08-21 11:45

reporter   ~0007098

Something like i submitted in the previous bug note would probably do this. I'm assuming we'd want it on all the time.

Also shows a 'total' row underneath for the total time spent within db_query.

Is this something we would apply?

thraxisp

thraxisp

2004-08-27 14:20

reporter   ~0007258

Paul's code was added to CVS with some changes.