3 // vim: expandtab sw=4 ts=4 sts=4:
5 * holds function for dumping profiling data
7 * allways use $GLOBALS here, as this script is included by footer.inc.hp
8 * which can also be included from inside a function
11 if ( ! empty( $GLOBALS['DBG'] )
12 && $GLOBALS['cfg']['DBG']['profile']['enable'] ) {
15 * Displays profiling results when called
16 * WARNING: this function is SLOW
18 function dbg_dump_profiling_results() {
19 /* Applies to the original 'dbg_dump_profiling_results' function,
20 * sourced from http://dd.cron.ru/dbg/download.php?h=prof_sample2
21 * Copyright (c) 2002. Dmitri Dmitrienko
22 * LICENCE: This source file is subject to Mozilla Public License (MPL)
23 * AUTHOR: Dmitri Dmitrienko <dd@cron.ru>
25 dbg_get_profiler_results( $dbg_prof_results = '' );
26 $cwdlen = strlen(getcwd()); // gma added var, $cwdlen = strlen(getcwd());
27 echo '<br /><table xml:lang="en" dir="ltr" width="1000" cellspacing="0" cellpadding="2" style="font:8pt courier">' . "\n" .
31 '<th>' . $GLOBALS['strDBGModule'] . '</th>' . "\n" .
32 '<th>' . $GLOBALS['strDBGLine'] . '</th>' . "\n" .
33 '<th>' . $GLOBALS['strDBGHits'] . '</th>' . "\n" .
34 '<th>' . $GLOBALS['strDBGTimePerHitMs'] . '</th>' . "\n" .
35 '<th>' . $GLOBALS['strDBGTotalTimeMs'] . '</th>' . "\n" .
36 '<th>' . $GLOBALS['strDBGMinTimeMs'] . '</th>' . "\n" .
37 '<th>' . $GLOBALS['strDBGMaxTimeMs'] . '</th>' . "\n" .
38 '<th>' . $GLOBALS['strDBGContextID'] . '</th>' . "\n" .
39 '<th>' . $GLOBALS['strDBGContext'] . '</th>' . "\n" .
40 '</tr>' . "\n"; // gma change "." to ";"
41 echo $tr.'</thead><tbody style="vertical-align: top">' . "\n";
42 $lines = 0; // gma added "echo $tr." and "$lines = 0;"
47 foreach ( $dbg_prof_results['line_no'] as $idx => $line_no ) {
48 dbg_get_module_name( $dbg_prof_results['mod_no'][$idx], $mod_name );
50 //if (strpos("!".$mod_name, 'dbg.php') > 0) continue;
52 $time_sum = $dbg_prof_results['tm_sum'][$idx] * 1000;
53 $time_avg_hit = $time_sum / $dbg_prof_results['hit_count'][$idx];
55 $time_sum = sprintf( '%.3f', $time_sum );
56 $time_avg_hit = sprintf('%.3f', $time_avg_hit);
57 $time_min = sprintf( '%.3f', $dbg_prof_results['tm_min'][$idx] * 1000 );
58 $time_max = sprintf( '%.3f', $dbg_prof_results['tm_max'][$idx] * 1000 );
59 dbg_get_source_context( $dbg_prof_results['mod_no'][$idx],
62 // use a default context name if needed
63 if ( dbg_get_context_name( $ctx_id, $ctx_name )
64 && strlen($ctx_name) == 0 ) {
68 if ( $time_avg_hit > $GLOBALS['cfg']['DBG']['profile']['threshold'] ) {
69 echo '<tr class="' . $odd_row ?
'odd' : 'even' . '">' .
70 // gma changed "$mod_name" to "substr($mod_name,$cwdlen+1)"
71 '<td>' . substr($mod_name,$cwdlen+
1) . '</td>' .
72 '<td>' . $line_no . '</td>' .
73 '<td>' . $dbg_prof_results['hit_count'][$idx] . '</td>' .
74 '<td>' . $time_avg_hit . '</td>' .
75 '<td>' . $time_sum . '</td>' .
76 '<td>' . $time_min . '</td>' .
77 '<td>' . $time_max . '</td>' .
78 '<td>' . $ctx_id . '</td>' .
79 '<td>' . $ctx_name . '</td>' .
82 // gma added line. Repeats the header every x lines.
83 if ( $lines === 19 ) {
88 $odd_row = ! $odd_row;
93 echo '</tbody></table>';
96 /* gma ... Developer Notes
97 These two scriptlets can be used as On/Off buttons in your browsers, add to links.
99 javascript: document.cookie = 'DBGSESSID=' + escape('1;d=1,p=1') + '; path=/'; document.execCommand('refresh');
101 javascript: document.cookie = 'DBGSESSID=' + escape('1;d=0,p=1') + '; path=/'; document.execCommand('refresh');
103 javascript: document.cookie = 'DBGSESSID=' + escape('1;d=0,p=0') + '; path=/'; document.execCommand('refresh');