XHProf

让程序员不再苦逼的四大神器

你。 提交于 2020-03-01 14:53:43
做程序猿「媛」是一个苦逼的活,大周六地早起在技术群里招呼,看到没有啥人响应,说了一句,「估计都没有醒」,然后一位哥们抛过来,「在加班」 ! 做 Web 开发更是一个苦逼的活,不像是做 iOS,搞定客户端,基本上就万事大吉了。做 Web 开发不仅仅是要做后端,前端也需要了解和熟悉! 做前后端通吃的 DevOps 全栈工程师绝对是最苦逼的活,不但需要做开发,而且还要了解运维、优化,不会运维的工程师绝对不是一个好架构师! 但所幸的事,一个优秀的工程师尽管很忙,尽管要熟悉前后端、系统、运营、优化,但是在他的工具箱里,放着一大堆工具,让这种生活变得不那么苦逼。 这里就介绍四个让我们 DevOps 生活变得美好的神器。分别是 Xdebug、XHProf 、 OneAPM 和 SocketLog。 Xdebug 作为开发人员,睡得最踏实的事是对自己写的代码了如指掌,无论是从功能层面,还是性能层面。而做 Web PHP 开发,比较棘手的一件事情就是代码的调试。作为脚本语言,在远程服务器端运行,客户端生成的全是 HTML 代码,一般认为我们无法准确地调试运行的情况,更不要说单步调试、变量监控等事情了。其实这是有误解的,有一个 PHP 扩展 Xdebug 能让方便地让我们调试远程服务器上运行的代码。 方法很简单,从 Xdebug 下载最新版的源代码。 wget 解压: tar –zxvf xdebug

Xdebug vs xhprof

江枫思渺然 提交于 2020-01-24 08:24:32
问题 I was using xdebug to profile the use of multi curl in my php code, and the numbers didn't add up to the total, so I used xhprof instead, which seemed to provide better data. Why is xdebug providing seemingly bad profiling info, and is there a way to work around it? I would prefer to use xdebug's profiler, as there are more tools for it. 回答1: Xdebug's profiler works in a slightly different way and thus gives different results. (I also know there is a little bug in aggregating data). I would

Can't install Xhprof in PHP 5.4

我只是一个虾纸丫 提交于 2020-01-05 06:32:08
问题 I'm getting the following error when trying to use xhprof in PHP 5.4 PHP Warning: PHP Startup: xhprof: Unable to initialize module Module compiled with module API=20090626 PHP compiled with module API=20100525 It looks like I have some conflict with PHP versions as I installed 5.4 some days ago. php-v shows 5.4 but php-config --version shows 5.3 and phpize shows API=20090626 while PHP is compiled with API=20100525 回答1: sudo apt-get install php5-dev In my case the solution was to upgrade the

Profiling Code on Production

孤街浪徒 提交于 2019-12-30 01:20:24
问题 I'm toying around with the idea of implementing something that profiles code on the production server and wanted some best-practice advice. Obviously it's a bad idea to profile ALL requests because of the added overhead so I was looking into some techniques that will randomly invoke the profiler per request. Something like 1 profile per every 10,000 requests. I know there is a way to achieve such a task with Facebook's XHProf Profiler but was hoping for a similar solution using xdebug. So my

xhprof not working wamp 2.2

浪子不回头ぞ 提交于 2019-12-12 04:08:32
问题 I have downloaded the dll file from http://windows.php.net/downloads/pecl/releases/xhprof/0.10.6/ and kept the first 32 bit file at C:\wamp\bin\php\php5.3.13\ext and also include it in my php.ini file (as extension=php_xhprof.dll). But when I call phpinfo() xhprof is now showing. I am not getting any errors in my log. 回答1: There are 2 php.ini file and you may have edited the wrong one. To make sure you edit the correct php.ini file i.e. the one used by Apache use the wampmanager menus like so

Xdebug vs xhprof

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I was using xdebug to profile the use of multi curl in my php code, and the numbers didn't add up to the total, so I used xhprof instead, which seemed to provide better data. Why is xdebug providing seemingly bad profiling info, and is there a way to work around it? I would prefer to use xdebug's profiler, as there are more tools for it. 回答1: Xdebug's profiler works in a slightly different way and thus gives different results. (I also know there is a little bug in aggregating data). I would always suggest to use both Xdebug and XHprof. 文章来源:

xhprof扩展安装与使用

匿名 (未验证) 提交于 2019-12-02 22:10:10
Ŀ¼ xhprof是PHP的一个扩展,最好也直接安装上graphviz图形绘制工具(用于xhprof分析结果以直观的图形方式显示),废话不多说,直奔正题。 PHP5版本的安装 wget http://pecl.php.net/get/xhprof-0.9.4.tgz tar -zxvf xhprof-0.9.4.tgz cd xhprof-0.9.4 cd extension/ phpize ./configure make make install PHP7版本的安装 unzip xhprof-php7.zip cd xhprof-php7/extension/ phpize ./configure --with-php-config=/usr/local/php/bin/php-config make make install 在php.ini配置文件中追加下面配置,并创建目录 /home/wwwroot/default/xhprof_data [xhprof] extension = xhprof.so // xhprof分析结果文件存放根目录 xhprof.output_dir = /home/wwwroot/default/xhprof_data 为了后期每个项目都能使用xhprof来进行性能分析,建议给PHP加一个环境变量,这样之后

xhgui doesn't save any data

大憨熊 提交于 2019-12-02 04:27:10
问题 I've installed all te prerequistes on an Ubuntu machine and added the following to my apache virtual host file php_admin_value auto_prepend_file "/var/www/xhgui/external/header.php" After visiting the site I then go to /xhgui/webroot and just see the message Looks like you haven't done any profiling Mongodb is running but it seems as though no data is being saved there. Any suggestions? Thanks 回答1: external/header.php has logic to simply return; if rand(0, 100) does not return the value 42.

Profiling Code on Production

久未见 提交于 2019-11-30 05:18:49
I'm toying around with the idea of implementing something that profiles code on the production server and wanted some best-practice advice. Obviously it's a bad idea to profile ALL requests because of the added overhead so I was looking into some techniques that will randomly invoke the profiler per request. Something like 1 profile per every 10,000 requests. I know there is a way to achieve such a task with Facebook's XHProf Profiler but was hoping for a similar solution using xdebug. So my questions are (assuming xdebug is the profiler): Is this kind of feature even advisable? I'd like to

使用brew报错:Bad credentials/GitHub API Error: API rate limit exceeded for

天涯浪子 提交于 2019-11-26 19:09:35
背景描述 XHProf是一个轻量级的PHP性能分析工具. 使用XHProf的时候,在点击[View Full Callgraph]查看结果分析图时,会报错, 原因是缺少graphviz绘图软件。 在使用 brew安装graphviz软件出现了一些错误,特此记录一下. 具体内容 首先使用brew搜索是否存在graphviz软件,报错: $ brew search graphviz Error: GitHub { "message": "Bad credentials", "documentation_url": "https://developer.github.com/v3" } The GitHub credentials in the OS X keychain may be invalid. Clear them with: printf "protocol=https\nhost=github.com\n" | git credential-osxkeychain erase Or create a personal access token: https://github.com/settings/tokens/new?scopes=&description=Homebrew and then set the token as: export HOMEBREW