Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profile Generate vs PG

Can anybody explain to me the difference between profile-generate and the pg options?

like image 232
Laser Avatar asked Sep 21 '12 12:09

Laser


1 Answers

Both will generate the profile data. But their usage differs.

fprofile-generate is to generate the binary with profiling information which you can re-use to give feedback to the compiler when you compile it again with fprofile-use.

For example:

$ gcc -fprofile-generate filename.c

If you execute the binary generated by the about command, it will produce a file called filename.gcda with profile data.

When you compile it with fprofile-use again:

$ gcc -fprofile-use filename.c

This time, gcc will use that data from filename.gcda to optimize further.

When you execute the binary which was compiled with -pg, it'll generate gmon.out which can be later used to analyze the code using gprof command. This is more like static analysis which will give information about code path.

like image 139
P.P Avatar answered Sep 26 '22 18:09

P.P