5

Is it possible to change the default name of the file gmon.out, which is created when the profile flag (-pg) is set when compiling with gcc, to, for example, [executable name].gmon.out?

I need this because I have more than one executables, which are located in the same directory, and have to run parallel.

0

2 Answers 2

14

Not so short, but actually the answer is YES - if using glibc (at least with version 2.11.1, which is the version I used to test this).

To have your -pg compiled and linked executable create different names then the default gmon.out, just set the environment variable GMON_OUT_PREFIX to a value of your choice and the profiling output will be written to [value of your choice].[pid] where [pid] is the process-ID of the process the profiling data belongs to.

2
  • A little late, but thank you very much for the answer. I'll keep that in mind. :)
    – Emiswelt
    Apr 17, 2011 at 11:53
  • 2
    You should really accept this answer, the other is simply false.
    – drrlvn
    Mar 27, 2013 at 22:28
0

In short, no. The profiling file created by running your program once it has been compiled with the -pg command is ALWAYS called gmon.out. However, once produced you can safely rename it to something else (for example foo.bar) and analyse it later using the command:

gprof test.exe foo.bar > analysis.txt
1
  • Thanks for your effort. Since this is not possible, I am now profiling with cachegrind and valgrind. This worked out for me.
    – Emiswelt
    Aug 31, 2010 at 13:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.