monitor(3C) monitor(3C)
NAME
monitor - prepare execution profile
SYNOPSIS
#include <mon.h>
void monitor (lowpc, highpc, buffer, bufsize, nfunc)
int (*lowpc)( ), (*highpc)( );
WORD *buffer;
int bufsize, nfunc;
DESCRIPTION
An executable program created by cc -p automatically
includes calls for monitor with default parameters; monitor
needn't be called explicitly except to gain fine control
over profiling.
monitor is an interface to profil(2). lowpc and highpc are
the addresses of two functions; buffer is the address of a
(user supplied) array of bufsize WORD (defined in the
<mon.h> header file). monitor arranges to record a
histogram in the buffer. This histogram shows periodically
sampled values of the program counter and counts of calls of
certain functions. The lowest address sampled is that of
lowpc; the highest address is just below highpc. lowpc may
not equal 0 for this use of monitor. nfunc is the maximum
number of call counts that can be kept; only calls of
functions compiled with the profiling option -p of cc(1) are
recorded. (The C Library and Math Library supplied when cc
-p is used also have call counts recorded.) For the results
to be significant, especially where there are small, heavily
used routines, it is suggested that the buffer be no more
than a few times smaller than the range of locations
sampled.
To profile the entire program, it is sufficient to use:
extern etext;
monitor ((int (*)())2, etext, buf, bufsize, nfunc);
etext lies just above all the program text; see end(3C).
To stop execution monitoring and write the results on the
file mon.out, use
monitor ((int (*)())0, 0, 0, 0, 0);
prof(1) can then be used to examine the results.
FILES
mon.out
/lib/libp/libc.a
Page 1 (last mod. 1/14/87)
monitor(3C) monitor(3C)
/lib/libp/libm.a
SEE ALSO
cc(1), prof(1), profil(2), end(3C).
Page 2 (last mod. 1/14/87)