Some newer profilers such as tcov can perform statement-by-statement profile...
Example:
CC -c -p file1.C # Profiling functions in file1.C CC -c file2.C # NO Profiling functions in file2.C CC -p -o myProg file1.o file2.o # Always need -p option in linking |
The execution will create a monitor output file mon.out
It is in a special format that is intended for a special program, so do not try to edit or view it....
prof myProg |
You will see different time results for different level of optimizations.
%Time Seconds Cumsecs #Calls msec/call Name 98.2 2.24 2.24 12750 0.1757 __1cBf6Fi_f_ // f() 1.8 0.04 2.28 50 0.8 __1cBg6Ff_f_ // g() 0.0 0.00 2.28 1 0. main |
Example:
CC -c --xprofile=tcov file1.C CC -c file2.C CC -xprofile=tcov -o myProg file1.o file2.o |
The execution will now create a monitor directory myProg.profile where "myProg" is the name of the executable program file
The coverage data is stored in program.profile/tcovd. You can view this file with an editor, but there is a better tool to use the data....
tcov -x myProg.profile programFile.C |
This will create a file programFile.C.tcov in the current directory and this file will contain the data from the "coverage analysis" merged with its source file.
A separate .tcov file will be created for each source file.
#include |