[英]How to parse number of instructions and elapsed time from output of perf stat
TL; DR
提供-x
時,有什么方法可以使性能perf stat
輸出時間過去?
背景
我執行了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
可能與我的需求有關,但是我無法弄清楚它的精確度。
如果(config->ru_display)
為true, print_footer
tools/perf/util/stat-display.c
文件的 print_footer
函數打印“經過的時間”。
但print_footer
沒有從所謂的perf_evlist__print_counters
當出現“ -x ,
”選項用於設置csv_output。
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模式下的perf stat輸出時間。
您可以修補stat-display.c
文件,你需要輸出任何東西和編譯perf
( cd tools/perf; make
)。 其他內核版本的perf工具可與任何linux內核一起使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.