View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008407 | mantisbt | performance | public | 2007-09-27 07:30 | 2007-10-04 01:37 |
Reporter | giallu | Assigned To | giallu | ||
Priority | normal | Severity | tweak | Reproducibility | have not tried |
Status | closed | Resolution | fixed | ||
Fixed in Version | 1.1.0rc1 | ||||
Summary | 0008407: Add caller function info to queries list | ||||
Description | When the $g_show_queries_list parameter is active, it would be useful to know where each of the shown queries was run; that would be a nice starting point for debugging purposes | ||||
Tags | No tags attached. | ||||
Attached Files | bug8407.patch (2,813 bytes)
Index: core/html_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/html_api.php,v retrieving revision 1.215 diff -u -r1.215 html_api.php --- core/html_api.php 20 Sep 2007 07:18:27 -0000 1.215 +++ core/html_api.php 27 Sep 2007 13:14:47 -0000 @@ -424,10 +424,10 @@ for ( $i = 0; $i < $t_count; $i++ ) { if ( ! in_array( $g_queries_array[$i][0], $t_shown_queries ) ) { $t_unique_queries++; - $g_queries_array[$i][2] = false; + $g_queries_array[$i][3] = false; array_push( $t_shown_queries, $g_queries_array[$i][0] ); } else { - $g_queries_array[$i][2] = true; + $g_queries_array[$i][3] = true; } } echo "\t", $t_unique_queries . ' unique queries executed.<br />', "\n"; @@ -436,12 +436,15 @@ $t_total = 0; for ( $i = 0; $i < $t_count; $i++ ) { $t_time = $g_queries_array[$i][1]; + $t_caller = $g_queries_array[$i][2]; $t_total += $t_time; - if ( true == $g_queries_array[$i][2] ) { - echo "\t", '<tr valign="top"><td style="color: red">', ($i+1), '</td><td style="color: red">', $t_time , '</td><td style="color: red">', string_html_specialchars($g_queries_array[$i][0]), '</td></tr>', "\n"; - } else { - echo "\t", '<tr valign="top"><td>', ($i+1), '</td><td>'. $t_time . '</td><td>', string_html_specialchars($g_queries_array[$i][0]), '</td></tr>', "\n"; + $t_style_tag = ''; + if ( true == $g_queries_array[$i][3] ) { + $t_style_tag = ' style="color: red"'; } + echo "\t", '<tr valign="top"><td', $t_style_tag, '>', ($i+1), '</td>'; + echo '<td', $t_style_tag, '>', $t_time , '</td>'; + echo '<td', $t_style_tag, " title=\"$t_caller\">", string_html_specialchars($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"; Index: core/database_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/database_api.php,v retrieving revision 1.68 diff -u -r1.68 database_api.php --- core/database_api.php 22 Sep 2007 22:21:15 -0000 1.68 +++ core/database_api.php 27 Sep 2007 13:14:47 -0000 @@ -160,7 +160,13 @@ $t_result = $g_db->Execute( $p_query ); } $t_elapsed = number_format( microtime_float() - $t_start, 4); - array_push ( $g_queries_array, array( $p_query, $t_elapsed ) ); + + $t_backtrace = debug_backtrace(); + $t_caller = basename( $t_backtrace[0]['file'] ); + $t_caller .= ":" . $t_backtrace[0]['line']; + $t_caller .= " " . $t_backtrace[1]['function'] . "()"; + + array_push ( $g_queries_array, array( $p_query, $t_elapsed, $t_caller ) ); if ( !$t_result ) { db_error($p_query); | ||||
Ok. I have a working patch for this, adding a title to each of the queries cell so that hovering with the mouse in the query (in the picture attached I was over 20) a string is shown with: filename:line function_name |
|
and here is the patch. Feel free to comment/request changes |
|
I agree with the need for the feature, I think it is really useful. I would rather have such info as normal text, so that people can copy and paste this text into performance related bug reports. Having it as text will also simplify the analysis of sources of duplicate bugs. Granted it will be more text, but this is debug output. We can put such info above each query. |
|
Done, with the additional line made in gray |
|
MantisBT: master 3b16d061 2007-09-27 17:34 Details Diff |
Fix 8407: Add caller function info to queries list git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4595 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9 |
Affected Issues 0008407 |
|
mod - core/html_api.php | Diff File | ||
mod - core/database_api.php | Diff File |