문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top