博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
xdebug+WinCacheGrind+qcachegrind来分析脚本执行时间
阅读量:3713 次
发布时间:2019-05-21

本文共 2154 字,大约阅读时间需要 7 分钟。

xdebug简介

Xdebug是php的一款调试工具,是基于zend的一个扩展,可以用来跟踪,调试和分析PHP程序的运行状况。如变量,函数调试,性能监测,代码覆盖率等


xdebug安装

1.下载xdebug源程序

git clone git://github.com/xdebug/xdebug.githttps://xdebug.org/download.php#releases

2.解压xdebug包

tar -xzvf xdebug.tgz

3.进入解压目录

cd xdebug

4.运行phpize

/usr/local/php/bin/phpize

5.编译

./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config

6.安装

make && make install

7.安装成功后会在php扩展目录生成类似xdebug.so的扩展

8.安装xdebug客户端xdebugclient (需要libedit扩展)

cd debugclient./configure --with-libeditmakemake install

xdebug配置

1.在php.ini配置文件中添加如下内容

zend_extension="/wherever/you/put/it/xdebug.so"
2.如果是php5.3之前版本线程安全,添加如下内容代替上面1的内容
zend_extension_ts="/wherever/you/put/it/xdebug.so"
3.自从php5.3之后zend_extension_ts, zend_extension_debug不再使用

4.xdebug的一些其他配置

;显示错误信息xdebug.default_enable = 1;函数调试xdebug.auto_trace=onxdebug.trace_output_dirxdebug.trace_output_name;Type: string, Default value: trace.%cxdebug.collect_params = 1|3|4 (参数长度,参数值,参数=值)xdebug.show_mem_delta=1 显示内存xdebug.collect_return=1 显示返回值xdebug.trace_options =1 追加日志xdebug.collect_params=1xdebug.collect_vars = 1;开启性能分析xdebug.profiler_enable=1;性能分析日志保存目录xdebug.profiler_output_dir = /data/logs/xdebug/;性能分析日志文件名称xdebug.profiler_output_name = cachegrind.out.log;默认是如下格式,t时间,p进程id;xdebug.profiler_output_name = cachegrind.out.%t.%p;代码覆盖率xdebug.coverage_enable = 1;以下是远程调试配置xdebug.remote_host= 127.0.0.1xdebug.remote_connect_back = 1xdebug.remote_port = 9000xdebug.remote_log="/data/logs/xdebug/xdebug.log"

4.重启php使配置生效


性能分析日志工具

1.linux平台

工具KCacheGrind (Linux, KDE) 

2.win平台查看工具WinCacheGrind

相关网址

http://ceefour.github.io/wincachegrind/https://sourceforge.net/projects/wincachegrind/https://github.com/ceefour/wincachegrind/releases/tag/1.1

列名称含义

Self - Shows the execution time of the code in the current block

Cum. - Shows the total exuction time of functions that the current function (Self) calls

Avg vs. Total: Average is average time per call, Total is the total time spend in all calls.

3.Web方式查看webgrind

https://github.com/jokkedk/webgrind

 

 

现在开始安装qcachegrind工具吧(因为我用的是mac所以这里介绍用mac安装方式):

(1)brew install graphviz    执行此命令安装graphviz,用来Call Graph功能(2)brew install qcachegrind    安装qcachegrind

转载地址:http://jfojn.baihongyu.com/

你可能感兴趣的文章
数据库原理—关系数据库
查看>>
虚拟机(vmware)中安装linux系统
查看>>
Python—海龟作图
查看>>
进制转换(m 进制 x 转换为 n 进制的数)
查看>>
Java—求素数
查看>>
python背单词小程序
查看>>
Java—10000000以内完美数
查看>>
软考网工—华为命令总结
查看>>
圆的内接正n边形的周长
查看>>
洛古P1518—两只塔姆沃斯牛
查看>>
Frame
查看>>
Frame-Pannel-Button综合
查看>>
选课小程序
查看>>
anaconda安装步骤
查看>>
画笔Paint及模拟画图工具
查看>>
Collection接口
查看>>
JDBC连接数据库
查看>>
无聊时候的故事分享
查看>>
LVM(逻辑卷管理器)
查看>>
Java实现超市管理系统(含数据库)
查看>>