Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
wdebug.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Set of usefull debug functions
8  *
9  * @author Anakeen
10  * @version $Id: wdebug.php,v 1.2 2008/12/11 15:16:21 eric Exp $
11  * @package FDL
12  * @subpackage CORE
13  */
14 /**
15  */
16 
18 global $TSQLDELAY;
19 $SQLDEBUG = true;
20 
21 function dtic($text = "")
22 {
23  static $ptic = 0;
24  static $ptic0 = 0;
25 
26  $deb = gettimeofday();
27  $tuc1 = $deb["sec"] + $deb["usec"] / 1000000;
28  if ($ptic == 0) {
29  $ptic = $tuc1;
30  $ptic0 = $tuc1;
31  }
32 
33  $msg = sprintf("%s : %.03f - %.03f ", $text, ($tuc1 - $ptic) , ($tuc1 - $ptic0));
34  $ptic = $tuc1;
35  return $msg;
36 }
37 
38 function dtrace($text)
39 {
40  global $trace;
41  global $TSQLDELAY;
42  $tsql = count($TSQLDELAY);
43  $trace[] = dtic($text) . "#$tsql";
44 }
45 
46 function stacktrace($level = 3, $uplevel = 1)
47 {
48  if (!function_exists('xdebug_get_function_stack')) return '';
49  $stack = xdebug_get_function_stack();
50  $t = array();
51  foreach ($stack as $k => $v) {
52  $t[] = sprintf("[%s:%d]%s", basename($v["file"]) , $v["line"], $v["function"]);
53  }
54  $l = (-1 - $level);
55  $t = array_slice($t, $l, -$uplevel);
56  return implode("/<br>", $t);
57 }
58 function dmtrace($text = "", $level = 3)
59 {
60  dtrace(stacktrace($level, 2) . ':' . $text);
61 }
62 
63 function printdtrace()
64 {
65 
66  global $trace;
67  foreach ($trace as $k => $v) {
68  //[test.php:26]AddFile/<br>[Class.Dir.php:276]updateFldRelations:updateFldRelations : 0.075 - 0.075 #17
69  if (preg_match("/(.*):([^-]+)-([^#]+)#(.*)$/", $v, $reg)) {
70  printf("%30.30s : %.03f | %02.03f | %d\n", substr($reg[1], -30) , $reg[2], $reg[3], $reg[4]);
71  }
72  }
73 }
74 ?>
$deb
Definition: indexq.php:20
printdtrace()
Definition: wdebug.php:63
$trace
Definition: indexq.php:77
dmtrace($text="", $level=3)
Definition: wdebug.php:58
global $SQLDELAY
Definition: wdebug.php:17
dtic($text="")
Definition: wdebug.php:21
dtrace($text)
Definition: wdebug.php:38
global $TSQLDELAY
Definition: wdebug.php:18
stacktrace($level=3, $uplevel=1)
Definition: wdebug.php:46
global $SQLDEBUG
Definition: wdebug.php:17
← centre documentaire © anakeen