Ubuntu 使用perfTools进行软件的性能分析
1.下载http://download.savannah.gnu.org/releases/libunwind/
https://sourceforge.net/projects/gperftools.mirror/
sudo apt-get install graphviz
-
在/usr/local/下解压
sudo tar -zxvf libunwind-1.6.0-rc2.tar.gz
sudo tar -zxvf cp /home/hlx/Downloads/gperftools-2.9.1.tar.gz -
cd 进入解压后的目录
-
安装库
./configure
sudo make
sudo make install -
pprof 所在目录加入环境变量
-
新建qt工程,链接库
LIBS +=-lprofiler
LIBS +=-lunwind
main.cpp如下 -
查看目录下生成的的.prof文件
pprof ./untitled a.prof –web
#include#include void f() { int i; for (i=0; i<1024*1024; ++i) { char *p = (char*)malloc(1024*1024*120); free(p); } } void fun1() { f(); } void fun2() { f(); } int main() { ProfilerStart("test.prof");//开启性能分析 fun1(); fun2(); fun1(); fun2(); ProfilerStop();//停止性能分析 return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)