开发者社区> 问答> 正文

perf命令的用法是什么?

perf命令的用法是什么?

展开
收起
1658458755422780 2021-03-31 15:46:36 1685 0
2 条回答
写回答
取消 提交回答
  • 下一站是幸福

    Perf 是用来进行软件性能分析的工具,可以利用 PMU,tracepoint 和内核中的特殊计数器来进行性能统计,用来分析内核和应用程序的性能

    以下面的实例,说明perf的基本用法

    //t1.c 
    void longa() 
    { 
      int i,j; 
      for(i = 0; i < 1000000; i++) 
      j=i; //am I silly or crazy? I feel boring and desperate. 
    } 
     
    void foo2() 
    { 
      int i; 
      for(i=0 ; i < 10; i++) 
           longa(); 
    } 
     
    void foo1() 
    { 
      int i; 
      for(i = 0; i< 100; i++) 
         longa(); 
    } 
     
    int main(void) 
    { 
      foo1(); 
      foo2(); 
    }
    
    /*t2.c*/
    int main(void) 
    {
    
    
    while (1);
    

    }

    2021-03-31 19:22:32
    赞同 展开评论 打赏
  • Performance Event:性能分析工具,基于“Performance counters”的内核子系统实现

    perf stat:获取特定程序的事件计数

    perf top:实时显示系统当前事件计数

    perf record:作用于perf stat类似,区别是结果输出到文件

    perf report:解析perf record生成的文件

    perf list:显示所有支持的事件类型

    perf probe:动态增加tracepoint

    2021-03-31 19:28:50
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载