我可以手动在xdebug分析器上说开始在特定位置进行分析吗? [英] Can I manually say on xdebug profiler to start profiling in specific place?

查看:85
本文介绍了我可以手动在xdebug分析器上说开始在特定位置进行分析吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的XAMPP安装中启用了xDebug分析,并且工作正常.

I already have enabled xDebug profiling in my XAMPP installation and it works fine.

现在我想问一下,是否有一种方法可以在我的源代码中说何时开始使用xDebug进行性能分析.

Now I like to ask if there is a way to say from within my source code when to start profiling with xDebug.

更具体地说,我想创建一个WordPress插件,我想说的是,从插件的起点开始分析,并在插件的终点停止分析.

More specific, I'd like to create a WordPress plugin, and I'd like to say, start profiling from the start point of the plugin and stop profiling at the end point of the plugin.

有可能吗?

注意:以上仅是示例.它可能是CakePHP插件,也可能是我可能需要剖析的新PHP类

Note: The above is just an example. It can be a CakePHP plugin or a new PHP Class that I may need to profile

推荐答案

Per How to Turn On/Off Xdebug Profiling at Runtime? you can't actually enable/disable at runtime (for example per function call).

您可以为每个请求有选择地启用探查器,通常更好. 要实现此行为,请设置以下设置:

You can selectively enable profiler per request, which is generally better. To achieve this behaviour set those settings:

xdebug.profiler_enable_trigger=1
xdebug.profiler_enable=0

请注意,我们禁用了探查器,仅启用了触发器. 从您的浏览器传递XDEBUG_PROFILE = 1

Note that we disable profiler and only enable the trigger. From your browser pass XDEBUG_PROFILE=1

http://example.com/file.php?XDEBUG_PROFILE=1

您也可以在POST或COOKIE中传递此参数.有关更多信息,请检查

You may also pass this parameter in POST or COOKIE. For more info check

  1. http://xdebug.org/docs/profiler#starting
  2. http://xdebug.org/docs/all_settings#profiler_enable_trigger
  1. http://xdebug.org/docs/profiler#starting
  2. http://xdebug.org/docs/all_settings#profiler_enable_trigger

这篇关于我可以手动在xdebug分析器上说开始在特定位置进行分析吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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