我正在尝试使用 xdebug 来分析用 php7 编写的应用程序。
我编写了一个脚本来设置以下 ini
设置:
ini_set('xdebug.trace_format',1); // Note: I tried 0 and 2 here as well
ini_set('xdebug.profiler_enable',1);
xdebug_start_trace('/tmp/cachegrind.out');
// RUN CODE HERE
xdebug_stop_trace();
运行脚本创建了我所期望的cachegrind文件:
root@host:/# ls /tmp | grep cachegrind
cachegrind.out.0028fd.xt
cachegrind.out.0072ab.xt
cachegrind.out.009b09.xt
cachegrind.out.025ac3.xt
这是 Cachegrind 文件的前几行,以便格式可见:
Version: 2.4.1
File format: 4
TRACE START [2016-10-28 05:26:57]
2 3784 1 0.242945 2692856
2 3785 0 0.242955 2692800 DI\Container->set 1 /path/public/api/index.php 100
2 3785 1 0.242966 2692800
2 3786 0 0.242973 2692800 spl_autoload_call 0 /path/public/api/index.php 103
3 3787 0 0.242982 2692896 Fuel\Core\Autoloader::load 1 /path/public/api/index.php 103
4 3788 0 0.242990 2692896 strpos 0 /path/fuel/core/classes/autoloader.php 219
但是,当我尝试在 qcachegrind
中打开此文件时,它无法打开:
错误消息显示:“加载 /path/to/cachegrind/file
时出错:未知文件格式
有人知道这是怎么回事吗?我希望能够使用这样的工具来分析我的应用程序。
我还花了 30 美元尝试打开 MCG 中的文件。但该应用程序在打开任何这些文件后立即崩溃。
顺便说一句,该文件相当大,但还没有大到我认为应用程序会崩溃的程度:
❯ ls -al /Users/johnpc/repos/cachegrind.out.094ffa.xt
-rw-r--r-- 1 johnpc staff 62744095 Oct 28 02:13 /Users/johnpc/repos/cachegrind.out.094ffa.xt
最佳答案
该文件是跟踪文件而不是 callgrind 文件。
我似乎将ini中的trace_output_name和profiler_output_name设置为相同的字符串或尝试打开错误的文件。您需要在 ini.ini 文件中设置 profiling_* 变量。 请参阅:xdebug docs 中的“分析 PHP 脚本”
示例分析输出如下所示:
version: 1
creator: xdebug 2.1.1rc1
cmd: /Users/foo/bar/test1.php
part: 1
positions: line
events: Time
fl=php:internal
fn=php::microtime
当您因文件大小而遇到问题时,您还可以尝试 profilingviewer.com 中的应用程序
关于php - qcachegrind错误: Unknown file format.从php xdebug生成的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40298853/