Linux下的应用程序性能分析 总结
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
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://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下的应用程序性能分析 总结的更多相关文章
- Linux程序性能分析和火焰图
Linux程序性能分析和火焰图 Linux程序的性能分析工具数量比较多,涉及到整个操作系统的方方面面,可能是开源的原因吧,相对于Windows来说丰富太多.其中应用分析性能方面Dtrace, Syst ...
- Linux下用火焰图进行性能分析【转】
转自:https://blog.csdn.net/gatieme/article/details/78885908 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原 ...
- Linux下利用Valgrind工具进行内存泄露检测和性能分析
from http://www.linuxidc.com/Linux/2012-06/63754.htm Valgrind通常用来成分析程序性能及程序中的内存泄露错误 一 Valgrind工具集简绍 ...
- Linux下如何查看高CPU占用率线程
转于:http://www.cnblogs.com/lidabo/p/4738113.html 目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidst ...
- Linux下配置Lamp
linux下配置lamp步骤: 一.快速安装Apache+PHP5+MySql 先更新: # yum update 然后安装LAMP环境:(163的yum源上只有php5.1.6 mysql 5.0. ...
- linux下阅读源代码的工具
说来真是惭愧呀.一直在用VIM 做开发.却不知道VI 里还有这么好使的工具.以前一直都是用: find -type f -print | xargs grep -i **** 在源代码里查找. 原来L ...
- Linux下如何查看高CPU占用率线程 LINUX CPU利用率计算
目录(?)[-] proc文件系统 proccpuinfo文件 procstat文件 procpidstat文件 procpidtasktidstat文件 系统中有关进程cpu使用率的常用命令 ps ...
- Linux下性能调试工具运维笔记
作为一名资深的linux运维工程师,为方便了解和追求服务器的高性能,如cpu.内存.io.网络等等使用情况,要求运维工程师必须要熟练运用一些必要的系统性能调试工具,liunx下提供了众多命令方便查看各 ...
- 八、jdk工具之JvisualVM、JvisualVM之二--Java程序性能分析工具Java VisualVM
目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...
随机推荐
- 大话PHP缓存头
304的请求机制和200有什么不一样呢?在fiddler中查看304请求的时候突然想到这个问题,就想到研究下这个304请求机制了. 我们自己在nginx上放一个文件,test.png.可以使用下面的地 ...
- linux的计划
我接触linux也有好几年了,至少有5年了.最近公司在搞内部培训,人人都可以报名培训别人.想到自己在linux浸淫多年,应该出来出一份力.一直以来想就linux写一个专题.今天刚好在做相关的ppt,借 ...
- C#如何调用COM
这章中描述的属性被用在创建和COM程序交互的程序中. 1.1 COMImport 属性 当被放在一个类上, COMImport 属性就把这个类标记为一个外部实现的COM 类.这样的一个类声明使得可以 ...
- AudioCapabilities成员
参考:http://www.ajerp.com/Cs/DirectX/Capture/DirectX.Capture.html 使用有道翻译2.0 AudioCapabilities成员 公共实例字段 ...
- Stream Player control
In this article you will find an implementation of a stream player control. Download WPF demo - 11 M ...
- ADB pm 命令
usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [--user USER_TER] pm list permission-grou ...
- asp.net session
简介编辑 session对象用于存储特定的用户会话所需的信息 . Session对象的引入是为了弥补HTTP协议的不足,HTTP协议是一种无状态的协议. Session中文是"会话" ...
- C#操作XML学习之创建XML文件的同时新建根节点和子节点(多级子节点)
最近工作中遇到一个问题,要求创建一个XML文件,在创建的时候要初始化该XML文档,同时该文档打开后是XML形式,但是后缀名不是.在网上找了好些资料没找到,只能自己试着弄了一下,没想到成功了,把它记下来 ...
- 【从API学英语】-PreparedStatement
原文 An object that represents a precompiled SQL statement. A SQL statement is precompiled and stored ...
- jquery更改加载图片大小
<script type="text/javascript"> $("img").css("width","80%&q ...