分析PHP代码 [英] Profiling PHP code

查看:71
本文介绍了分析PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一种方法来确定PHP中的每个函数以及PHP中的每个文件需要花费多长时间.我有一个旧的旧版PHP应用程序,试图在其中找到粗糙点",因此,我想客观地确定哪些例程和页面需要花费很长时间来加载.

I'd like to find a way to determine how long each function in PHP, and each file in PHP is taking to run. I've got an old legacy PHP application that I'm trying to find the "rough spots" in and so I'd like to locate which routines and pages are taking a very long time to load, objectively.

是否有任何允许使用此功能的预制工具,还是我只能使用microtime并构建自己的性能分析框架?

Are there any pre-made tools that allow for this, or am I stuck using microtime, and building my own profiling framework?

推荐答案

上周我实际上已经做了一些优化工作. XDebug确实是必经之路.

I have actually done some optimisation work last week. XDebug is indeed the way to go.

只需将其作为扩展名(由于某种原因,它将无法与我的Windows计算机上的ze_extension一起使用),使用xdebug.profiler_enable_trigger = On设置php.ini并使用XDEBUG_PROFILE = 1调用您的常规网址或发布变量来描述该请求.没有比这更简单的事了!

Just enable it as an extension (for some reason it wouldn't work with ze_extension on my windows machine) , setup your php.ini with xdebug.profiler_enable_trigger=On and call your normal urls with XDEBUG_PROFILE=1 as either a get or a post variable to profile that very request. There's nothing easier!

此外,我真的可以推荐 webgrind (基于网络(php)的Google Summer Of Code)可以读取和解析调试输出文件的项目!

Also, i can really reccommend webgrind , a webbased (php) google Summer Of Code project that can read and parse your debug output files!

这篇关于分析PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆