Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何解析perf stat输出的指令数和运行时间_Linux_Profiling_Perf - Fatal编程技术网

Linux 如何解析perf stat输出的指令数和运行时间

Linux 如何解析perf stat输出的指令数和运行时间,linux,profiling,perf,Linux,Profiling,Perf,TL;DR 当提供-x时,是否有任何方法使性能统计输出时间经过 背景 我执行了perf stat-e指令:u make run,输出粘贴在下面 Performance counter stats for 'make run': 53,781,961,288 instructions:u 2.802749955 seconds time elapsed 21.453244000 seconds user 0.249223000 se

TL;DR

当提供
-x
时,是否有任何方法使
性能统计
输出时间经过

背景

我执行了
perf stat-e指令:u make run
,输出粘贴在下面

 Performance counter stats for 'make run':

    53,781,961,288      instructions:u

       2.802749955 seconds time elapsed

      21.453244000 seconds user
       0.249223000 seconds sys
53781782267,,instructions:u,20694056846,100.00,,
我想分析指令的数量和经过的时间,因此我添加了
-x
选项,以使输出用逗号分隔,相应的输出粘贴在下面

 Performance counter stats for 'make run':

    53,781,961,288      instructions:u

       2.802749955 seconds time elapsed

      21.453244000 seconds user
       0.249223000 seconds sys
53781782267,,instructions:u,20694056846,100.00,,
我注意到没有显示所有的时间测量值,所以我检查了
perf help stat
的输出。在
CSV格式
部分,我发现计数器的
运行时间
可选度量值
,和
可选度量单位
可能与我的需要有关,但我不知道具体是如何进行的。

从if
打印页脚
功能(配置-/ru\u显示)打印“经过的时间”
是正确的

但是当存在设置csv输出的“
-x,
”选项时,不会从
perf\u evlist\u\u print\u计数器中调用
print\u footer

if (!interval && !config->csv_output)
    print_footer(config);
“用户”/“系统”时间在
config->ru\u data.ru\u-utime
ru\u data.ru\u-stime
中,而“经过的秒数”是
config->walltime\u-stats
的平均值

stat display.c
中没有其他代码显示
ru_data.ru_utime
ru_data.ru_stime
walltime\u nsecs\u stats
,因此在Linux内核版本4.20中,无法以CSV模式从perf stat输出时间


您可以修补
stat display.c
文件以输出所需的任何内容,并编译
perf
cd-tools/perf;make
)。来自其他内核版本的perf工具将适用于任何linux内核。

您的
perf
和linux内核的版本是什么?@osgx perf:
4.19.g84df95
,linux内核:
4.17.11-arch1
(by
uname-r
)您可以尝试使用
perf stat/usr/bin/time-f'%e,%U,%s./your_程序
从GNU时间程序获取运行时间,或使用不同格式的字符串。感谢您的详细解释。那是不是意味着我必须得1。下载linux内核源代码2。根据需要修改
/tools/perf/util/stat display.c
。编译它并用原始性能替换它?我还想知道这是否会影响其他用户,因为我正在工作站上工作。抱歉,如果您觉得这听起来很傻,我正在学习关于linux的第一门课程,并努力熟悉它:)David,您可以尝试
perf stat/usr/bin/time-f FORMAT_STRING
解决方案。或者,您可以下载内核源代码,将dir更改为tools/perf,编辑文件并运行make。如果您不能(或不应该)替换system perf binary,只需从它所在的位置运行它(或将它复制到您的一些目录,如
/home/david/bin/perf
)。我最终使用了
格式字符串解决方案,感谢您提供的所有信息!