Xhprof Application

WBOY
Release: 2016-07-28 08:25:47
Original
1279 people have browsed it

For a long time, I have used a small plug-in written by myself for PHP debugging and running performance monitoring, and I feel that it is okay. But when I was browsing around just now, I found something called Xhprof. After a brief look at the introduction, it seemed to be similar to my little plug-in. I would like to sort out the applications of Xhprof and compare it with my plug-in.

Official website

<code><span>http:</span>//www<span>.xhprof</span><span>.com</span>/</code>
Copy after login

Install

<code>wget http:<span>//pecl.php.net/get/xhprof-0.9.4.tgz</span>
tar zxf xhprof<span>-</span><span>0.9</span><span>.4</span><span>.</span>tgz
cd xhprof<span>-</span><span>0.9</span><span>.4</span>/extension<span>/</span>
phpize
<span>.</span>/configure <span>--</span><span>with</span><span>-php</span><span>-config</span><span>=</span>/usr/<span>local</span>/php/bin/php<span>-config</span>
make
make install</code>
Copy after login

Configure PHP.ini

<code><span># vi /usr/local/php/etc/php.ini</span></code>
Copy after login
<code>[xhprof]
extension=xhprof<span>.so</span><span>;</span>
xhprof<span>.output</span>_dir=/tmp/xhprof</code>
Copy after login

Application 1

<code><span><span><?php</span>
xhprof_enable();
【PHP业务代码】
<span>$data</span> = xhprof_disable();
<span>// xhprof_lib在下载的包里存在这个目录,记得将目录包含到运行的php代码中</span><span>include_once</span><span>"xhprof_lib/utils/xhprof_lib.php"</span>;  
<span>include_once</span><span>"xhprof_lib/utils/xhprof_runs.php"</span>;  

<span>$objXhprofRun</span> = <span>new</span> XHProfRuns_Default(); 

<span>// 第一个参数j是xhprof_disable()函数返回的运行信息</span><span>// 第二个参数是自定义的命名空间字符串(任意字符串),</span><span>// 返回运行ID,用这个ID查看相关的运行结果</span><span>$run_id</span> = <span>$objXhprofRun</span>->save_run(<span>$data</span>, <span>"xhprof"</span>);
var_dump(<span>$run_id</span>);</span></span></code>
Copy after login

Application 2

<code><span><span><?php</span><span>//cpu:XHPROF_FLAGS_CPU 内存:XHPROF_FLAGS_MEMORY,这两个都是整形常量,可以相加</span>
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
【PHP业务代码】
<span>$data</span> = xhprof_disable();
</span></code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced the Xhprof application, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!