cari
Rumahpembangunan bahagian belakangtutorial phpPHP性能分析工具XHProf安装使用教程_PHP教程

PHP性能分析工具XHProf安装使用教程

   这篇文章主要介绍了PHP性能分析工具XHProf安装使用教程,本文给出详细安装步骤和配置方法以及使用实例,需要的朋友可以参考下

  HProf是facebook开源出来的一个php轻量级的性能分析工具,跟Xdebug类似,但性能开销更低,还可以用在生产环境中,也可以由程序开关来控制是否进行profile。基于浏览

  器的性能分析用户界面能更容易查看,或是与同行们分享成果。也能绘制调用关系图。在数据收集阶段,它记录调用次数的追踪和包容性的指标弧在动态callgraph的一个程序。

  它独有的数据计算的报告/后处理阶段。在数据收集时,XHProfd通过检测循环来处理递归的函数调用,并通过给递归调用中每个深度的调用一个有用的命名来避开死循环。

  XHProf的轻量级性质和汇聚功能,使得它非常适合用于收集“生产环境”的性能统计数据的统计。

  1. 安装XHProf

  代码如下:

  wget http://pecl.php.net/get/xhprof-0.9.2.tgz

  tar zxf xhprof-0.9.2.tgz

  cd xhprof-0.9.2

  cp -r xhprof_html xhprof_lib

  cd extension

  phpize

  ./configure

  make

  make install

  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.

  ; 记得WEB要有写入权限

  xhprof.output_dir=

  重启服务让修改生效,现在就可以使用XHProf了,不过为了显示效果更炫,最好继续安装Graphviz。

  3. 安装Graphviz

  代码如下:

  wget http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.26.3.tar.gz

  tar zxf graphviz-2.26.3.tar.gz

  cd graphviz-2.26.3

  ./configure

  make

  make install

  安装完成后,会生成/usr/local/bin/dot文件,你应该确保路径在PATH环境变量里,以便XHProf能找到它。

  4. 应用XHProf

  复制代码 代码如下:

  xhprof_enable();//打开xhprof

  /******程序逻辑 Start******/

  function test1(){

  sleep(3);

  return;

  }

  function test2(){

  test1();

  }

  function test3(){

  test2();

  }

  function p(){

  echo '

xhprof test

';

 

  }

  p();

  test3();

  /******程序逻辑 End******/

  $xhprof_data = xhprof_disable();//关闭xhprof

  //保存xhprof数据

  include_once '../xhprof_lib/utils/xhprof_lib.php';

  include_once '../xhprof_lib/utils/xhprof_runs.php';

  $xhprof_runs = new XHProfRuns_Default();

  $xhprof_source = 'xhprof_test';

  $run_id = $xhprof_runs->save_run($xhprof_data, $xhprof_source);

  $report_url = 'http://xhprof.rebill.info/index.php?run='.$run_id.'&source='.$xhprof_source;

  echo '
';

  echo 'view the performance report:'.$report_url.'';

  如此一来,会在上面设定的xhprof.output_dir目录里生成名字类似4c236583ef490.xhprof_test的数据文件,可以很方便的通过Web方式浏览效果:

  http://xhprof.rebill.info/index.php?run=4c236583ef490&source=xhprof_test

  目前显示的是表格形式的显示,点击页面上的[View Full Callgraph],就能看到精美的图片显示了。

  在线测试体验地址:http://xhprof.rebill.info/test.php

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1000088.htmlTechArticlePHP性能分析工具XHProf安装使用教程 这篇文章主要介绍了PHP性能分析工具XHProf安装使用教程,本文给出详细安装步骤和配置方法以及使用实例...
Kenyataan
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
php怎么把负数转为正整数php怎么把负数转为正整数Apr 19, 2022 pm 08:59 PM

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php怎么实现几秒后执行一个函数php怎么实现几秒后执行一个函数Apr 24, 2022 pm 01:12 PM

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php怎么除以100保留两位小数php怎么除以100保留两位小数Apr 22, 2022 pm 06:23 PM

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

php怎么根据年月日判断是一年的第几天php怎么根据年月日判断是一年的第几天Apr 22, 2022 pm 05:02 PM

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php怎么替换nbsp空格符php怎么替换nbsp空格符Apr 24, 2022 pm 02:55 PM

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\&nbsp\;||\xc2\xa0)/","其他字符",$str)”语句。

php怎么判断有没有小数点php怎么判断有没有小数点Apr 20, 2022 pm 08:12 PM

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

php怎么设置implode没有分隔符php怎么设置implode没有分隔符Apr 18, 2022 pm 05:39 PM

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

php怎么读取字符串后几个字符php怎么读取字符串后几个字符Apr 22, 2022 pm 08:31 PM

在php中,可以使用substr()函数来读取字符串后几个字符,只需要将该函数的第二个参数设置为负值,第三个参数省略即可;语法为“substr(字符串,-n)”,表示读取从字符串结尾处向前数第n个字符开始,直到字符串结尾的全部字符。

See all articles

Alat AI Hot

Undresser.AI Undress

Undresser.AI Undress

Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover

AI Clothes Remover

Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool

Undress AI Tool

Gambar buka pakaian secara percuma

Clothoff.io

Clothoff.io

Penyingkiran pakaian AI

AI Hentai Generator

AI Hentai Generator

Menjana ai hentai secara percuma.

Alat panas

EditPlus versi Cina retak

EditPlus versi Cina retak

Saiz kecil, penyerlahan sintaks, tidak menyokong fungsi gesaan kod

Dreamweaver Mac版

Dreamweaver Mac版

Alat pembangunan web visual

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Persekitaran pembangunan bersepadu PHP yang berkuasa

SublimeText3 versi Mac

SublimeText3 versi Mac

Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

mPDF

mPDF

mPDF ialah perpustakaan PHP yang boleh menjana fail PDF daripada HTML yang dikodkan UTF-8. Pengarang asal, Ian Back, menulis mPDF untuk mengeluarkan fail PDF "dengan cepat" dari tapak webnya dan mengendalikan bahasa yang berbeza. Ia lebih perlahan dan menghasilkan fail yang lebih besar apabila menggunakan fon Unicode daripada skrip asal seperti HTML2FPDF, tetapi menyokong gaya CSS dsb. dan mempunyai banyak peningkatan. Menyokong hampir semua bahasa, termasuk RTL (Arab dan Ibrani) dan CJK (Cina, Jepun dan Korea). Menyokong elemen peringkat blok bersarang (seperti P, DIV),