ubuntu 16.04安装 perf

本文档记录了在 Ubuntu 16.04 系统上安装 perf 的详细步骤,包括通过 `apt` 安装所需的依赖包,并解决在安装过程中遇到的问题。安装完成后,使用 `perf stat` 命令测试了一个名为 `test` 的程序,展示了 perf 收集到的性能统计数据。

安装

tsh@tsh-virtual-machine:~/codeTest/learnPerf$ perf stat ./test
The program 'perf' is currently not installed. You can install it by typing:
sudo apt install linux-tools-common


tsh@tsh-virtual-machine:~/codeTest/learnPerf$ sudo apt install linux-tools-common
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  linux-tools-common
0 upgraded, 1 newly installed, 0 to remove and 329 not upgraded.
Need to get 140 kB of archives.
After this operation, 565 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-tools-common all 4.4.0-142.168 [140 kB]
Fetched 140 kB in 5s (23.6 kB/s)             
Selecting previously unselected package linux-tools-common.
(Reading database ... 182683 files and directories currently installed.)
Preparing to unpack .../linux-tools-common_4.4.0-142.168_all.deb ...
Unpacking linux-tools-common (4.4.0-142.168) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up linux-tools-common (4.4.0-142.168) ...


tsh@tsh-virtual-machine:~/codeTest/learnPerf$ sudo perf stat ./test
WARNING: perf not found for kernel 4.8.0-36

  You may need to install the following packages for this specific kernel:
    linux-tools-4.8.0-36-generic
    linux-cloud-tools-4.8.0-36-generic

  You may also want to install one of the following packages to keep up to date:
    linux-tools-generic
    linux-cloud-tools-generic


tsh@tsh-virtual-machine:~/codeTest/learnPerf$ sudo apt-get install linux-tools-4.8.0-36-generic  linux-cloud-tools-4.8.0-36-generic  linux-tools-generic    linux-cloud-tools-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libdw1 linux-cloud-tools-4.4.0-142 linux-cloud-tools-4.4.0-142-generic linux-cloud-tools-common linux-hwe-cloud-tools-4.8.0-36 linux-hwe-tools-4.8.0-36 linux-tools-4.4.0-142
  linux-tools-4.4.0-142-generic
The following NEW packages will be installed:
  libdw1 linux-cloud-tools-4.4.0-142 linux-cloud-tools-4.4.0-142-generic linux-cloud-tools-4.8.0-36-generic linux-cloud-tools-common linux-cloud-tools-generic linux-hwe-cloud-tools-4.8.0-36
  linux-hwe-tools-4.8.0-36 linux-tools-4.4.0-142 linux-tools-4.4.0-142-generic linux-tools-4.8.0-36-generic linux-tools-generic
0 upgraded, 12 newly installed, 0 to remove and 329 not upgraded.
Need to get 1,806 kB of archives.
After this operation, 8,191 kB of additional disk space will be used.
Do you want to continue? [Y/n] y^[[A
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libdw1 amd64 0.165-3ubuntu1.1 [192 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-cloud-tools-common all 4.4.0-142.168 [57.3 kB]                                                                        
Get:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-cloud-tools-4.4.0-142 amd64 4.4.0-142.168 [64.4 kB]                                                                   
Get:4 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-cloud-tools-4.4.0-142-generic amd64 4.4.0-142.168 [2,546 B]                                                           
Get:5 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-hwe-cloud-tools-4.8.0-36 amd64 4.8.0-36.36~16.04.1 [40.0 kB]                                                          
Get:6 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-cloud-tools-4.8.0-36-generic amd64 4.8.0-36.36~16.04.1 [1,820 B]                                                      
Get:7 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-cloud-tools-generic amd64 4.4.0.142.148 [2,296 B]                                                                     
Get:8 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-hwe-tools-4.8.0-36 amd64 4.8.0-36.36~16.04.1 [718 kB]                                                                 
Get:9 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-tools-4.4.0-142 amd64 4.4.0-142.168 [721 kB]                                                                          
Get:10 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-tools-4.4.0-142-generic amd64 4.4.0-142.168 [2,598 B]                                                                
Get:11 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-tools-4.8.0-36-generic amd64 4.8.0-36.36~16.04.1 [1,896 B]                                                           
Get:12 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-tools-generic amd64 4.4.0.142.148 [2,286 B]                                                                          
Fetched 1,806 kB in 3min 44s (8,036 B/s)                                                                                                                                                        
Selecting previously unselected package libdw1:amd64.
(Reading database ... 182732 files and directories currently installed.)
Preparing to unpack .../libdw1_0.165-3ubuntu1.1_amd64.deb ...
Unpacking libdw1:amd64 (0.165-3ubuntu1.1) ...
Selecting previously unselected package linux-cloud-tools-common.
Preparing to unpack .../linux-cloud-tools-common_4.4.0-142.168_all.deb ...
Unpacking linux-cloud-tools-common (4.4.0-142.168) ...
Selecting previously unselected package linux-cloud-tools-4.4.0-142.
Preparing to unpack .../linux-cloud-tools-4.4.0-142_4.4.0-142.168_amd64.deb ...
Unpacking linux-cloud-tools-4.4.0-142 (4.4.0-142.168) ...
Selecting previously unselected package linux-cloud-tools-4.4.0-142-generic.
Preparing to unpack .../linux-cloud-tools-4.4.0-142-generic_4.4.0-142.168_amd64.deb ...
Unpacking linux-cloud-tools-4.4.0-142-generic (4.4.0-142.168) ...
Selecting previously unselected package linux-hwe-cloud-tools-4.8.0-36.
Preparing to unpack .../linux-hwe-cloud-tools-4.8.0-36_4.8.0-36.36~16.04.1_amd64.deb ...
Unpacking linux-hwe-cloud-tools-4.8.0-36 (4.8.0-36.36~16.04.1) ...
Selecting previously unselected package linux-cloud-tools-4.8.0-36-generic.
Preparing to unpack .../linux-cloud-tools-4.8.0-36-generic_4.8.0-36.36~16.04.1_amd64.deb ...
Unpacking linux-cloud-tools-4.8.0-36-generic (4.8.0-36.36~16.04.1) ...
Selecting previously unselected package linux-cloud-tools-generic.
Preparing to unpack .../linux-cloud-tools-generic_4.4.0.142.148_amd64.deb ...
Unpacking linux-cloud-tools-generic (4.4.0.142.148) ...
Selecting previously unselected package linux-hwe-tools-4.8.0-36.
Preparing to unpack .../linux-hwe-tools-4.8.0-36_4.8.0-36.36~16.04.1_amd64.deb ...
Unpacking linux-hwe-tools-4.8.0-36 (4.8.0-36.36~16.04.1) ...
Selecting previously unselected package linux-tools-4.4.0-142.
Preparing to unpack .../linux-tools-4.4.0-142_4.4.0-142.168_amd64.deb ...
Unpacking linux-tools-4.4.0-142 (4.4.0-142.168) ...
Selecting previously unselected package linux-tools-4.4.0-142-generic.
Preparing to unpack .../linux-tools-4.4.0-142-generic_4.4.0-142.168_amd64.deb ...
Unpacking linux-tools-4.4.0-142-generic (4.4.0-142.168) ...
Selecting previously unselected package linux-tools-4.8.0-36-generic.
Preparing to unpack .../linux-tools-4.8.0-36-generic_4.8.0-36.36~16.04.1_amd64.deb ...
Unpacking linux-tools-4.8.0-36-generic (4.8.0-36.36~16.04.1) ...
Selecting previously unselected package linux-tools-generic.
Preparing to unpack .../linux-tools-generic_4.4.0.142.148_amd64.deb ...
Unpacking linux-tools-generic (4.4.0.142.148) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up libdw1:amd64 (0.165-3ubuntu1.1) ...
Setting up linux-cloud-tools-common (4.4.0-142.168) ...
Setting up linux-cloud-tools-4.4.0-142 (4.4.0-142.168) ...
Setting up linux-cloud-tools-4.4.0-142-generic (4.4.0-142.168) ...
Setting up linux-hwe-cloud-tools-4.8.0-36 (4.8.0-36.36~16.04.1) ...
Setting up linux-cloud-tools-4.8.0-36-generic (4.8.0-36.36~16.04.1) ...
Setting up linux-cloud-tools-generic (4.4.0.142.148) ...
Setting up linux-hwe-tools-4.8.0-36 (4.8.0-36.36~16.04.1) ...
Setting up linux-tools-4.4.0-142 (4.4.0-142.168) ...
Setting up linux-tools-4.4.0-142-generic (4.4.0-142.168) ...
Setting up linux-tools-4.8.0-36-generic (4.8.0-36.36~16.04.1) ...
Setting up linux-tools-generic (4.4.0.142.148) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for ureadahead (0.100.0-19) ...

最后使用
tsh@tsh-virtual-machine:~/codeTest/learnPerf$ sudo perf stat ./test

 Performance counter stats for './test':

        188.210281      task-clock (msec)         #    0.998 CPUs utilized          
                 0      context-switches          #    0.000 K/sec                  
                 0      cpu-migrations            #    0.000 K/sec                  
                42      page-faults               #    0.223 K/sec                  
   <not supported>      cycles                                                      
   <not supported>      instructions                                                
   <not supported>      branches                                                    
   <not supported>      branch-misses                                               

       0.188575137 seconds time elapsed

tsh@tsh-virtual-machine:~/codeTest/learnPerf$ 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值