• perf 简介


    Perf 简介

    1.Perf简介

    PerfLinux kernel自带的系统性能优化工具。虽然它的版本还只是0.0.2Perf已经显现出它强大的实力,足以与目前Linux流行的OProfile相媲美了。

    Perf的优势在于与Linux Kernel的紧密结合,它可以最先应用到加入Kernelnew feature。而像OProfile, GProf等通常会慢一拍Perf的基本原理跟OProfile等类似,也是在CPUPMU registersGet/Set performance counters来获得诸如instructions executed, cache-missed suffered, branches mispredicted等信息。Linux kernel对这些registers进行了一系列抽象,所以你可以按进程,按CPU或者按counter group等不同类别来查看Sample信息。

    2.使用Perf

    $ perf record -f -- git gc

    $ perf report --sort comm,dso,symbol | head -10

    perf record相当于opcontrol --start, perf report相当于opreport.

    查看所有可用的counters'perf list’

    可以用以上counter的任意组合来跑测试程序。如,用以下命令来看跑hackbenchpage alloc/free的次数。

    perf stat -e kmem:mm_page_pcpu_drain -e kmem:mm_page_alloc ./hackbench 10

    Perf可以统计N次结果的数值波动情况:perf stat --repeat 5 -e kmem:mm_page_pcpu_drain -e kmem:mm_page_alloc ./hackbench 10

    perf record -f -e kmem:mm_page_alloc -c 1 ./git gc查看哪个function引起了page allocations

    titan:~/git> perf report

    titan:~/git> perf report --sort comm,dso,symbol

    同时,call-graph(函数调用图)也可以被记录下来,并且能告诉你每个函数所占用的百分比。

    titan:~/git> perf record -f -g -e kmem:mm_page_alloc -c 1 ./git gc

    titan:~/git> perf report -g

    用以下命令查看整个系统10秒内的page allocation次数:

    titan:~/git> perf stat -a -e kmem:mm_page_pcpu_drain -e kmem:mm_page_alloc sleep 10

    以下命令查看每隔1秒,系统page allocation的波动状况:

    titan:~/git> perf stat --repeat 10 -a kmem:mm_page_alloc sleep 1

    通过反汇编往往能找出是哪行代码生成的指令会引起问题。

    titan:~/git> perf annotate __GI___fork

    原文

    http://blog.csdn.net/bluebeach/article/details/5912062

    https://perf.wiki.kernel.org/index.php/Tutorial

    http://whatot.github.io/pub/linux_program/perf%E7%AE%80%E4%BB%8B/

  • 相关阅读:
    iOS UITableView的cell重用标识
    iOS SDWebImage清理缓存数据
    iOS UITextView 根据输入text自适应高度
    iOS 网络请求 NSURLSession 的上传文件方法
    iOS开发之tintColor属性详解
    iOS SDWEBImage和collectionView的组合,以及collectionView的随意间距设置
    iOS9 Xcode7 设置Launch Image 启动图片
    iOS
    iOS 浅谈AFNetworking网络请求
    贝塞尔曲线
  • 原文地址:https://www.cnblogs.com/mydomain/p/3204416.html
Copyright © 2020-2023  润新知