home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume8
/
prof.msc
/
README
< prev
next >
Wrap
Text File
|
1989-08-19
|
2KB
|
47 lines
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[0] ) 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 (dds@cc.ic.ac.uk)
Myrsinis 1
GR-145 62 Kifisia
GREECE