Linux下的应用程序性能分析 总结
2013-10-21 16:25
337 查看
Linux下的应用程序性能分析,根据内核程序和应用程序的不同,下文分两类进行描述。
我们侧重的是应用级别的程序,推荐google perf tool/kcachegrind组合
# 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/
/article/2836665.html
http://www.ibm.com/developerworks/cn/linux/l-oprof/
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.
1.在程序编译时选择-g -pg选项,插入必要的信息
2.运行程序后输出gmon.out信息
3.查看gmon.out,可以看到相关的信息
这个的效果不太好
http://blog.csdn.net/stanjiang2010/article/details/5655143
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
/article/4762486.html
/article/4762487.html
详细资料参考
http://ajsm5iagih.l6.yunpan.cn/lk/Qn2w6bg4BgZqU 工具_Linux程序性能剖析.doc
我们侧重的是应用级别的程序,推荐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 时可以访问之 ) ,并采样置于内核的缓冲区内。后者在后台运行,负责从内核空间收集数据,写入文件。/article/2836665.html
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//article/4762486.html
/article/4762487.html
详细资料参考
http://ajsm5iagih.l6.yunpan.cn/lk/Qn2w6bg4BgZqU 工具_Linux程序性能剖析.doc
相关文章推荐
- CentOS 安装中文输入法
- Linux设备驱动模型 bus_type bus_attribute device driver
- 我的centos6.2无线驱动安装--- 一路还很顺
- Linux批量杀进程
- Linux IPC总结(全)
- linux下IPTABLES配置详解
- centos 5 系统安装后
- 在linux上用dd命令实现ghost功能
- C/C++ Linux 程序员必须了解的 10 个工具
- How to Protect GRUB with Password in RHEL / CentOS / Fedora Linux
- linux实现的802.1q vlan
- 如何在Linux上安装OpenFire
- linux下热插拔事件的产生是怎样通知到用户空间,kobject_uevent_env之uevent , kset !!!
- linux 使用logrotate做日志轮替
- linux 内核开发基础
- Linux的crontab安装和详解
- Linux之runlevel
- 如何修改IP
- UNIX/LINUX 平台可执行文件格式分析
- redhat 4 结合 AD域认证,并以AD用户登录linux