就算内心讨厌也要学会微笑^_^,这个世界不会在乎你的感受。

gprof—Ubuntu中使用gprofile进行性能统计时没有数字结果

gprof 实验

关键在于编译的时候禁用PIE就可以了
gcc -pg -O0 -fno-pie -static test.c -o test

 



/*test.c*/

#include<stdio.h> #include <stdlib.h> void TestFunc(); static void StaticFunc(); void TestFunc() { int i = 0; printf("In TestFunc\n"); for (i=0; i<20; i++) StaticFunc(); } static void StaticFunc() { int i = 0; printf("In StaticFunc\n"); for (i=0; i<1000000000; i++); } int main(void) { printf("In main\n"); TestFunc(); return 0; }

 


在terminal中编译运行
gcc -pg -O0 -fno-pie -static test.c -o test

./test

gprof test > data.txt

 

运行结果




一些输出选项后面补。。。

posted @ 2017-12-08 16:47  Syntax  阅读(877)  评论(0编辑  收藏  举报