case 2 (for system 2) Wait, that is not the end. If returning result of $uname -r is like this 4.4.77, the previous way may not work. If you do $sudo apt-get install linux-tools-4.4.77 but cannot get the tool installed. In this case, download the required linux kernel version (our case is v4.4.77) and go to ‘linux->tools->perf’ to install it. $git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git After download finished, $cd linux-stable/ $git checkout v4.4.77 (you can also check your git status git status) $cd tools/perf/ $make (If error came and asked for installation of ‘flex’ and ‘bison’, $sudo apt-get install flex and $sudo apt-get install bison) $sudo cp perf /usr/bin After doing this, you can try $perf --version and hope it works for you now. After make, you can also try make install and then check the perf --version.
perf stat -p 49298
perf record -e cpu-clock -p 49298
Performance counter stats for process id '49298': 26,955.53 msec task-clock:u # 1.037 CPUs utilized 0 context-switches:u # 0.000 K/sec 0 cpu-migrations:u # 0.000 K/sec 179,775 page-faults:u # 6669.449 M/sec 46,899,747,932 cycles:u # 1739927.580 GHz 59,990,994,484 instructions:u # 1.28 insn per cycle 13,567,779,293 branches:u # 503349259.618 M/sec 72,828,426 branch-misses:u # 0.54% of all branches 26.003937135 seconds time elapsed