Sunday, March 28, 2010

Generating Profile data files for multi-process programs

Generating Profile data files for multi-process programs

Gprof uses profiling data files (i.e gmon.out) to generate profiling information. gmon.out files are generated by compiling and linking a program with the -pg option. The program is then executed and on a normal shutdown (either through a return 0 from main() or by invoking the exit() system call) the gmon.out file is generated in the process' current working directory.

In a multi-process program, the gmon.out file generated could either be corrupted or could have incomplete profiling information. This could happen because each of the process' end up writing (or overwriting) to the same gmon.out file.

One solution to this problem would be to create a separate directory for each of the executables and then run the multi-process program. gmon.out files for each process can then be found in their respective directories (unless the program invokes chdir() system call).

Author: mwnn <mwnnlin AT gmail DOT com>

Date: 2010-03-28 10:20:38 IST

HTML generated by org-mode 6.21b in emacs 23

No comments:

Post a Comment