39.5. 获取有关指定事件的统计信息
您可以使用 perf stat
命令查看特定事件。
流程
使用
perf stat
功能查看上下文切换数:# perf stat -e context-switches -a sleep 5 ^Performance counter stats for 'sleep 5': 15,619 context-switches 5.002060064 seconds time elapsed
结果显示发生 5 秒,15619 上下文切换。
通过运行脚本查看文件系统活动。以下示例显示了脚本示例:
# for i in {1..100}; do touch /tmp/$i; sleep 1; done
在另一个终端中运行
perf stat
命令:# perf stat -e ext4:ext4_request_inode -a sleep 5 Performance counter stats for 'sleep 5': 5 ext4:ext4_request_inode 5.002253620 seconds time elapsed
结果显示,在 5 秒之内要求创建 5 个文件,这表示有 5 个
索引节点
请求。