TL; DR
提供perf stat
时,有没有办法使-x
输出时间过去?
背景
我执行了perf stat -e instructions: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
我想解析指令的数量和经过的时间,所以我添加了-x
选项,以逗号分隔输出,并将相应的输出粘贴在下面。
53781782267,,instructions:u,20694056846,100.00,,
我注意到并未显示所有时间测量值,因此我检查了perf help stat
的输出。在CSV FORMAT
部分中,我发现run time of counter
,optional metric value
和optional unit of metric
可能与我的需求有关,但我不知道具体如何。< / p>
答案 0 :(得分:0)
print_footer
为真,则从tools/perf/util/stat-display.c
file的(config->ru_display)
函数中打印“经过的时间”。
但是,如果存在用于设置csv_output的“ print_footer
”选项,则不会从perf_evlist__print_counters
调用-x ,
。
if (!interval && !config->csv_output)
print_footer(config);
“用户” /“ sys”时间分别在config->ru_data.ru_utime
和ru_data.ru_stime
中,而“经过的秒数”是config->walltime_nsecs_stats
的平均值。
stat-display.c
中没有其他代码可以显示ru_data.ru_utime
,ru_data.ru_stime
或walltime_nsecs_stats
,因此在Linux内核版本4.20中,无法从性能输出时间。 CSV模式下的统计信息。
您可以修补stat-display.c
文件以输出所需的任何内容并编译perf
(cd tools/perf; make
)。其他内核版本的perf工具可与任何Linux内核一起使用。