Linux下的应用程序性能分析,根据内核程序和应用程序的不同,下文分两类进行描述。

我们侧重的是应用级别的程序,推荐google perf tool/kcachegrind组合

一、和内核有关的工具

既可以处理内核,又可以处理应用的程序,但安装需要对内核代码有处理,所以有些麻烦

(一)Perf

#1 必须在root下编译

# perf

pushd /usr/src

bzip2 -d linux-source-2.6.32.tar.bz2

tar -xvf linux-source-2.6.32.tar -C .

popd

pushd /usr/src/linux-source-2.6.32/tools/perf

make

make install

popd

cp -f /root/bin/perf /usr/bin/.

perf --version

Perf -- Linux下的系统性能调优工具

http://www.ibm.com/developerworks/cn/linux/l-cn-perf1/

http://www.ibm.com/developerworks/cn/linux/l-cn-perf2/

(二)Oprofile

oprofile 在 Linux 上分两部分,一个是内核模块 (oprofile.ko) ,一个为用户空间的守护进程 (oprofiled) 。前者负责访问性能计数器或者注册基于时间采样的函数 ( 使用 register_timer_hook 注册之,使时钟中断处理程序最后执行 profile_tick 时可以访问之 ) ,并采样置于内核的缓冲区内。后者在后台运行,负责从内核空间收集数据,写入文件。

http://blog.csdn.net/yili_xie/article/details/4925648

http://www.ibm.com/developerworks/cn/linux/l-oprof/

(三)LTTNG

http://lttng.org/

The LTTng project aims at providing highly efficient tracing tools for Linux. Its tracers help tracking down performance issues and debugging problems involving multiple concurrent processes and threads. Tracing across multiple systems is also possible.

Apart from LTTng's kernel tracer and userspace tracer, viewing and analysis tools are part of the project. The LTTV viewer permits to analyze and show traces, both in text format and graphically.

二、应用工具

(一)Gprof (kprof)

主要的步骤:

1.在程序编译时选择-g -pg选项,插入必要的信息

2.运行程序后输出gmon.out信息

3.查看gmon.out,可以看到相关的信息

这个的效果不太好

http://blog.csdn.net/stanjiang2010/article/details/5655143

(二)google perf tool (kcachegrind)

#gperftools-2.1 说明文档说明了在64下的问题

tar -xzvf libunwind-1.1.tar.gz  -C .

#libunwind 0.99 1.0.1 编译错误

pushd libunwind-1.1

./configure --prefix=/usr

make

make install

popd

rm -r -f libunwind-1.1

#gperftools-2.1

tar -xzvf gperftools-2.1.tar.gz  -C .

pushd gperftools-2.1

./configure --prefix=/usr

make

make install

popd

rm -r -f gperftools-2.1

程序中插入性能的信息

ProfilerStart("demo.prof");

benchPasrer = boost::make_shared<antlr::AntlrMSSQLParser>();

for(int i=0; i< 1000; i++){

demo();

}

ProfilerStop();

查看

pprof –text  demo demo.prof --lines

pprof --text demo demo.prof --functions

和kcachegrind 整合在一起,图形查看

% pprof –callgrind demo demo.prof > demo.callgrind

% kcachegrind demo.callgrind

https://code.google.com/p/gperftools/

http://www.road2stat.com/cn/r/rprofiling.html

(三)Valgrind

http://valgrind.org/

http://www.cnblogs.com/2018/p/3228174.html

http://www.cnblogs.com/2018/p/3230736.html

详细资料参考

http://ajsm5iagih.l6.yunpan.cn/lk/Qn2w6bg4BgZqU  工具_Linux程序性能剖析.doc

Linux下的应用程序性能分析 总结的更多相关文章

  1. Linux程序性能分析和火焰图

    Linux程序性能分析和火焰图 Linux程序的性能分析工具数量比较多,涉及到整个操作系统的方方面面,可能是开源的原因吧,相对于Windows来说丰富太多.其中应用分析性能方面Dtrace, Syst ...

  2. Linux下用火焰图进行性能分析【转】

    转自:https://blog.csdn.net/gatieme/article/details/78885908 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原 ...

  3. Linux下利用Valgrind工具进行内存泄露检测和性能分析

    from http://www.linuxidc.com/Linux/2012-06/63754.htm Valgrind通常用来成分析程序性能及程序中的内存泄露错误 一 Valgrind工具集简绍 ...

  4. Linux下如何查看高CPU占用率线程

    转于:http://www.cnblogs.com/lidabo/p/4738113.html 目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidst ...

  5. Linux下配置Lamp

    linux下配置lamp步骤: 一.快速安装Apache+PHP5+MySql 先更新: # yum update 然后安装LAMP环境:(163的yum源上只有php5.1.6 mysql 5.0. ...

  6. linux下阅读源代码的工具

    说来真是惭愧呀.一直在用VIM 做开发.却不知道VI 里还有这么好使的工具.以前一直都是用: find -type f -print | xargs grep -i **** 在源代码里查找. 原来L ...

  7. Linux下如何查看高CPU占用率线程 LINUX CPU利用率计算

    目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidstat文件 procpidtasktidstat文件 系统中有关进程cpu使用率的常用命令 ps ...

  8. Linux下性能调试工具运维笔记

    作为一名资深的linux运维工程师,为方便了解和追求服务器的高性能,如cpu.内存.io.网络等等使用情况,要求运维工程师必须要熟练运用一些必要的系统性能调试工具,liunx下提供了众多命令方便查看各 ...

  9. 八、jdk工具之JvisualVM、JvisualVM之二--Java程序性能分析工具Java VisualVM

    目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...

随机推荐

  1. Azure China (2) Azure China管理界面初探

    <Windows Azure Platform 系列文章目录> 首先是Q&A时间 1.我在Azure Global拥有测试账号或者免费的MSDN订阅账号,这个账号可以在国内Azur ...

  2. web项目中,视图层中关于相对路径和绝对路径

    1.在jfinal项目中 因为一直使用的jfinal,没感觉路径问题. 举个栗子,项目名字叫做test.访问一个Controller的映射为/user/add.这样,在浏览器地址栏直接:localho ...

  3. [Java 基础]数组

    数组初始化 定义数组语法格式 定义数组有两种方式,如下两种格式是等价的: int[] a1; int a1[];  注:在C/C++中,不支持第一种格式.但是,推荐使用这种方式,因为这样似乎更合理,声 ...

  4. MVC学习之前必须掌握的c#基础知识

    一.类自动属性 public class Person { //自动属性 public string Name { get; set; } private int _age; public int a ...

  5. SQL--触发器

  6. 使用WebKit.net加载HTML编辑器

    关于webkit.net使用请看这里http://www.cnblogs.com/linyijia/p/4045333.html nicedit编辑器请到这里下载http://www.nicedit. ...

  7. 获取枚举值上的Description特性说明

    /// <summary> /// 获取枚举值上的Description特性说明 /// </summary> /// <typeparam name="T&q ...

  8. 点击一个div隐藏另一个div

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. mysql学习笔记 第六天

    改变数据表的结构: alter table tb_name action,[action,action](使用alter table 之前,需要查看数据表的当前定义,需要执行show create t ...

  10. 动态加载HTML后使用query修改标签样式

    下面的IMG 标签的宽度从后台返回是10PX,加载完毕后,修改成100PX,注意:拼接的代码在 body标签之后,或则直接在HTML外面增加也可以 <html> <head> ...