直接使用工具:perf
如下例子:
1.首先使用top查出占用cpu高进程:
如我的右图下角进程,我要查进程2418的cpu使用情况。
2.sudo perf top -p 2418
右下角就会出现函数占用多少,非常方便。
关于perf工具安装:
ubuntu:~$ perf
程序“perf”尚未安装。 您可以使用以下命令安装:
sudo apt install linux-tools-common
ubuntu:~$ sudo apt install linux-tools-common
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
ubuntu:~$ perf
WARNING: perf not found for kernel 4.4.0-24
You may need to install the following packages for this specific kernel:
linux-tools-4.4.0-24-generic
linux-cloud-tools-4.4.0-24-generic
You may also want to install one of the following packages to keep up to date:
linux-tools-generic
linux-cloud-tools-generic
ubuntu:~$ sudo apt-get install linux-tools-4.4.0-24-generic linux-cloud-tools-4.4.0-24-generic linux-tools-generic linux-cloud-tools-generic
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
这就就可以完成安装。