This profiler is exclusively written in Turbo C. It only requires a
single line to be placed in main() to profile all non-static functions
in a PROGRAM :
PROGRAM must be compiled with either the Public or Detailed linker map option.
Executing PROGRAM creates a text file : prof.out
Entering the command : profprt
Outputs (stdout) the report. The -h flag of profprt outputs a simple
*** Original README file for Microsoft C version follows ***
Included here is the source for an execution profiling system that can
be used with the Microsoft C or the Microsoft Quick C compiler. It
gives the time percentage a program spends in different functions. It
is an indispensable tool when trying to optimise a program. The system
has been tested with Microsoft C Version 5.00.
In order to use the profiler first create the object files sprof.obj,
lprof.obj, mprof.obj and cprof.obj by typing ``make''. The makefile
supplied expects a Un*x compatible linker, so if you are using the one
that came with the compiler do the compilations by hand.
Compile your program in such a way as to create a linker map file. To
do this link your program with the -Fm option of cl or the /MAP option
of the linker. The appropriate [slmc]prof.obj module has to be linked
together with the rest of the program. The first letter of the module
indicates the memory model in use. The program should call the
function prof_start( argv ) for versions of MS-DOS above or equal to
3.00 or prof_start( .map file name ) for MS-DOS versions before 3.00 in
order to start profiling. When the program finishes the profiler
automatically produces a prof.out file that contains the names of all
public symbols and the number of hits for each one.
You can read the results directly from the prof.out file, or you can
summarize them using profprt. Profprt reads the prof.out file (or
another file if specified) and produces a list of hits and percentages
for the functions for which hits were recorded. If given a -h option it
also produces a histogram of the relative timings.
A small test program is included to check the profiler functioning. It
generally found the profiler results to be within 1% of the expected
results on an 8MHz PC.
The profiler is all written in C utilizing the ability to create
interrupt handlers in C. It finds the addresses of the functions from
the linker map file. It should not be very hard to modify the source
for other compilers. Keep in mind that functions declared as static
are not included in the map file, thus will not be profiled and plan
accordingly. One solution is to compile with -Dstatic= if the naming
scheme used allows it. Pay attention to quantization errors and to
errors due to incorrectly specified boundaries. Portions of the code
that are executed with interrupts disabled will not be profiled.
Diomidis D. Spinellis ([email protected]
GR-145 62 Kifisia