Skip to content
/ xhprof Public

Easy XHprof, 为了更方便的使用XHprof

Notifications You must be signed in to change notification settings

luo3555/xhprof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XHPROF

1. pecl 安装

sudo pecl install xhprof

1.1 编译安装

wget https://pecl.php.net/get/xhprof-0.9.4.tgz
tar zxf xhprof-0.9.4.tgz
cd xhprof-0.9.4/extension/
sudo phpize
./configure --with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make install

1.2 安装 phpize 如果本地没有 phpizephp-config 需要单独安装

sudo apt-get install phpize
sudo apt-get install php-config

默认安装如果要安装指定版本需要

apt-cache search phpize | grep phpize

对应自己的 PHP 版本查看, 安装自己 PHP 对应的版本

php -v

2. 配置 php.ini

[xhprof]
extension=xhprof.so;
; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;
;xhprof.output_dir=<where_you_want_to_save_xhprof_output_file>
xhprof.output_dir=/tmp/xhprof

注意:

  1. 如果是64位系统需要将xhprof.so文件拷贝到相关的lib64的目录下
  2. xhprof.output_dir 对应第四步中的 output 文件夹路径

3. 如果出现错误 failed to execute cmd: " dot -Tpng". stderr: sh: 1: dot: not found ', 所以需要先安装 graphviz

4. 文件夹结构介绍

root
| -- output  测试输出的结果文件,位置需要配置到 xhprof.output_dir
|
| -- public_html `XHprof自带的查看测试结果代码根目录,访问这里可以查看结果;xhprof 下载解压后得到,将带 xhprof_html 文件夹下的内容拷贝到这里`
|
| -- track
|  | -- index.php 简化后的测试用文件
|
| -- xhprof_lib `XHprof 自己的类库,xhprof 下载解压后得到`

5. 使用介绍

  • track/index.php中定义自己XHPROF_ROOT的位置和XHprof的域名
  • 将要测试网站的index.php文件改名为index.php.bak
  • track/index.php放到要测试的网站根目录
  • 如果header中没有自定义`HTTP_XHPROF`和HTTP_XHPROF_JUMP这两个字段可以直接将index.php中的这两个参数改为true
  • 为了动态的开关XHprof我们可以安装Firefox插件Modify Headers来帮助我们实现动态开关
  • 代码地址 https://github.com/luo3555/xhprof.git

About

Easy XHprof, 为了更方便的使用XHprof

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages