部署xhprof监控php效率

WBOY
Libérer: 2016-06-20 13:05:24
original
788 Les gens l'ont consulté

部署xhprof监控php效率

1、安装xhprof扩展

 

下载地址:https://pecl.php.net/package/xhprof

2、配置php.ini

[xhprof]
extension=xhprof.so
xhprof.output_dir=/tmp
Copier après la connexion

3、下载web界面程序并部署
下载地址:https://github.com/phacility/xhprof
将apache或者nginx解析地址解析到xhprof_html目录

4、在你需要监控的页面或者应用中添加代码
a/页头添加如下代码

if (extension_loaded('xhprof')) {
xhprof_enable();
}
Copier après la connexion

b/页尾添加如下代码

if (extension_loaded("xhprof")) {
$xhprof_name = "test001";
$XHPROF_ROOT = "/vagrant_data/xhprof";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_data = xhprof_disable();
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, $xhprof_name);
echo "---------------\n".
"Assuming you have set up the http based UI for \n".
"XHProf at some address, you can view run at \n".
"http://192.168.33.10:9998/index.php?run=$run_id&source=xhprof_foo\n".
"---------------\n";
}
Copier après la connexion

5、访问解析到xhprof的url


Étiquettes associées:
php
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!