php - 使用 Xdebug 配置 cachegrind 时遇到问题

标签 php linux xdebug cachegrind

我正在尝试为 cachegrind 配置 Xdebug,但我无法启用探查器功能以转储已执行的网页。

我正在使用 the official guide (还有一些具有类似设置的)并且它似乎不起作用。

我已经在我的两台 Linux 机器(Ubuntu 和 Fedora)上试过了。 Xdebug 可以很好地进行调试,我可以为应用程序启动 valgrind --tool=cachegrind,因此两者都应该正确安装。

我在 php.ini 中激活和停用 profiler_enable 和 profiler_enable_trigger 选项并重新启动服务器,但没有成功。更改了输出目录,因为我认为它可能与权限有关。在 URL 中使用 ?XDEBUG_PROFILER=1 标志作为参数似乎也无济于事。

关于cachegrind的配置还有其他线索吗?

最佳答案

下面的基本 xdebug.ini 应该可以解决问题:

; check that the path is ok for you
zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.profiler_enable=1
xdebug.profiler_output_name = cachegring.out.%s
xdebug.profiler_output_dir = /tmp

请注意,它为每个请求启用分析器,这是一个重要的性能问题。但是,您应该首先测试这是否有效。如果您发现它有效,请默认禁用它。


关于 valgrind。

请注意,您尝试执行的操作是不可能的。 xdebug 探查器并非旨在与 valgrind 一起使用/连接到 valgrind。它只是使用与 valgrind 相同的输出格式。因此,格式与例如相同:

valgrind --tool=cachegrind --cachegrind-out-file=test.cachegrind ls -al

通常,您将使用 GUI 程序分析 cachegrind 文件,例如在 Linux 上使用 kcachegrind,在 Windows 上使用 wincachegrind

关于php - 使用 Xdebug 配置 cachegrind 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15260675/

相关文章:

php - "Notice: Undefined variable"、 "Notice: Undefined index"、 "Warning: Undefined array key"和 "Notice: Undefined offset"使用 PHP

php - 将推文存储到数据库中的简单方法是什么?

linux - 速度测试消耗多少带宽?

xdebug - 如何使用 xdebug 跟踪我的 curl

php - Codeception codecoverage 非常慢

php - 如何获得以像素为单位的固定宽度的完整单词的子字符串

linux - tail -F 无中断

linux - Ansible 和有条件的软件安装

xdebug - 如何在 MAC High Sierra 标准安装中使用 xdebug

php - 复制 PDO 对象会创建多个连接吗?