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

gprof 实验

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

 



/*test.c*/

#include #include 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

 

运行结果




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

待续。。。

转载于:https://www.cnblogs.com/zuoyaoAC/p/8006115.html

你可能感兴趣的:(gprof—Ubuntu中使用gprofile进行性能统计时没有数字结果)