ubuntu下安装c++检测工具perf
sudo apt-get install linux-tools-common
sudo apt-get install linux-tools-4.4.0-62-generic
sudo apt-get install linux-cloud-tools-4.4.0-62-generic
使用:
将它编译为可执行文件 test1
gcc – o test1 – g test.c
注意:此处一定要加-g选项,加入调试和符号表信息。
执行:
perf stat ./test1
Perf top
Perf top 用于实时显示当前系统的性能统计信息。该命令主要用来观察整个系统当前的状态,比如可以通过查看该命令的输出来查看当前系统最耗时的内核函数或某个用户进程。
4.1查找时间上的热点函数
perf record – e cpu-clock ./test1
perf report
sudo apt-get install linux-tools-common
sudo apt-get install linux-tools-4.4.0-62-generic
sudo apt-get install linux-cloud-tools-4.4.0-62-generic
使用:
将它编译为可执行文件 test1
gcc – o test1 – g test.c
注意:此处一定要加-g选项,加入调试和符号表信息。
执行:
perf stat ./test1
Perf top
Perf top 用于实时显示当前系统的性能统计信息。该命令主要用来观察整个系统当前的状态,比如可以通过查看该命令的输出来查看当前系统最耗时的内核函数或某个用户进程。
4.1查找时间上的热点函数
perf record – e cpu-clock ./test1
perf report
本文介绍如何在Ubuntu系统中安装并使用C++性能检测工具perf。通过几个简单的步骤完成安装,并展示了如何利用perf进行代码的性能分析,包括编译选项、执行命令以及如何使用perftop实时显示系统性能。
2751

被折叠的 条评论
为什么被折叠?



