run `perf stat` on the output of `perf record`?
使用
我可以在
在计数模式下,
在分析模式(采样分析)中,
1 2 3 4 5 6 7 8 9 10 11 12 | $ echo '3^123456%3' | perf stat bc 0 Performance counter stats for 'bc': 325.604672 task-clock (msec) # 0.998 CPUs utilized 0 context-switches # 0.000 K/sec 0 cpu-migrations # 0.000 K/sec 181 page-faults # 0.556 K/sec 828,234,675 cycles # 2.544 GHz 1,840,146,399 instructions # 2.22 insn per cycle 348,965,282 branches # 1071.745 M/sec 15,385,371 branch-misses # 4.41% of all branches 0.326152702 seconds time elapsed |
记录
1 2 3 | $ echo '3^123456%3' | perf record bc [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.049 MB perf.data (1293 samples) ] |
使用
1 2 3 4 5 | $ perf report --header |grep event # event : name = cycles:uppp, , size = 112, { sample_period, sample_freq } = 4000, sample_type = IP|TID|TIME|PERIOD ... # Samples: 1K of event 'cycles:uppp' $ perf script 2>/dev/null |grep cycles|wc -l 1293 |
perf.data中有一些时间戳,还有一些用于程序启动和退出的其他事件(
1 2 | $ perf report --header |grep Event # Event count (approx.): 836622729 |
使用
1 2 3 4 5 6 7 8 9 10 11 | $ echo '3^123456%3' | perf record -e cycles,instructions,branches,branch-misses bc [ perf record: Captured and wrote 0.238 MB perf.data (5164 samples) ] $ perf report --header |egrep Event\\|Samples # Samples: 1K of event 'cycles' # Event count (approx.): 834809036 # Samples: 1K of event 'instructions' # Event count (approx.): 1834083643 # Samples: 1K of event 'branches' # Event count (approx.): 347750459 # Samples: 1K of event 'branch-misses' # Event count (approx.): 15382047 |
因此,您不能在
不,你不能。性能记录输出是一个数据文件。性能统计期望应用程序。
您可以使用perf脚本运行预定义的脚本,以汇总和汇总跟踪数据。可以使用以下命令列出可能的脚本。
性能脚本-l
除了数量有限的预定义脚本之外,您还可以在python或perl中定义自定义perf.data处理脚本。
有关详细信息,请参见perf脚本,python中的perf脚本和perl中的perf脚本。