如何从性能统计信息输出中解析指令数量和经过的时间

时间:2019-01-03 11:58:27

标签: linux profiling perf

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 counteroptional metric valueoptional unit of metric可能与我的需求有关,但我不知道具体如何。< / p>

1 个答案:

答案 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_utimeru_data.ru_stime中,而“经过的秒数”是config->walltime_nsecs_stats的平均值。

stat-display.c中没有其他代码可以显示ru_data.ru_utimeru_data.ru_stimewalltime_nsecs_stats,因此在Linux内核版本4.20中,无法从性能输出时间。 CSV模式下的统计信息。

您可以修补stat-display.c文件以输出所需的任何内容并编译perfcd tools/perf; make)。其他内核版本的perf工具可与任何Linux内核一起使用。

相关问题