一、跟踪程序的运行
1.跟踪日志是调用php的函数或方法的列表,每个跟踪日志随机每个页面的执行不同而不同
2.xdebug支持两种类型日志格式,默认的格式人易读的格式,另外一种是机器易读的格式3.全日志的配置如下:
xdebug.auto_trace=On
xdebug.trace_output_dir="data.txt"
4.部份日志
在程序
xdebug_start_trace('D:\xampp\tmp');
php程序
xdebug_stop_trace();
TRACE START [2007-10-26 12:18:48]
0.0068 53384 -> fac() C:\www\fac.php:5
0.0069 53584 -> fac() C:\www\fac.php:10
0.0069 53840 -> fac() C:\www\fac.php:10
0.0070 54096 -> fac() C:\www\fac.php:10
0.0070 54376 -> fac() C:\www\fac.php:10
0.0071 54656 -> fac() C:\www\fac.php:10
0.0072 54936 -> fac() C:\www\fac.php:10
0.0072 55216 -> fac() C:\www\fac.php:10
0.0073 55392 -> xdebug_stop_trace() C:\www\fac.php:13
0.0237 55392
TRACE END [2007-10-26 12:18:48]
第一列表示总的执行时间,第二列表示执行时占用的内存,第三列表示所在文件,函数,所在行
xdebug.show_mem_delta=On
可以用来显示两行之间内存的大小
xdebug_start_trace(param1,param2)中
param2可以下列三个值:
XDEBUG_TRACE_APPEND以添加的方式写日志文件
XDEBUG_TRACE_COMPUTERIZED表示创建机器易读的的日志,和xdebug.trace_format to 1功能一样
XDEBUG_TRACE_HTML创建html格式的日志
5.记录传给函数的参数
xdebug.collect_params
0表示不收集
4表示显示变量名和所的函数参数
3表示显示函数名和参数,和去尾by xdebug.var_display_max_data, debug.var_display_max_children, and xdebug.var_display_max_depth
如:
0.0033 54320 -> fac($x = 7) C:\www\fac.php:6
0.0034 54432 -> fac($x = 6) C:\www\fac.php:11
6.记录函数的返回值
xdebug.collect_return=On
7.跟踪日志的文件名
xdebug.trace_output_name=
%c for the CRC checksum of the current working directory
%p for the process id
%r for a random number
%u for a timstamp with microseconds
%H the $_SERVER['HTTP_HOST']
%R the $_SERVER['REQUEST_URI']
xdebug_get_tracefile_name(()获取当前日志文件名
分析程序
1.分析php的性能:
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "D:/wamp/tmp"
分析日志是机器易读的,可以设置的选项不多
2.日志文件名可以有的选项
%p for the process id
%r for a random number
%u for a timstamp with microseconds
%H for the value of $_SERVER['HTTP_HOST']
%R for the value of $_SERVER['REQUEST_URI']
%s the name including full path, with slashes converted to underscores
xdebug.profiler_append=On日志以添加方式写文件