分析 PHP 代码 [英] Profiling PHP code

查看:24
本文介绍了分析 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 调用您的普通 URL 作为获取或用于描述该请求的帖子变量.没有比这更容易的了!

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) 的谷歌代码之夏可以读取和解析调试输出文件的项目!

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天全站免登陆