BSD 3 development
[unix-history] / usr / man / man3 / monitor.3
CommitLineData
e6817382
BJ
1.TH MONITOR 3
2.SH NAME
3monitor \- prepare execution profile
4.SH SYNOPSIS
5.B monitor(lowpc, highpc, buffer, bufsize, nfunc)
6.br
7.B
8int (*lowpc)( ), (*highpc)( );
9.br
10.B short buffer[ ];
11.SH DESCRIPTION
12An executable program created by
13`cc \-p' automatically includes calls for
14.I monitor
15with default parameters;
16.I monitor
17needn't be called explicitly
18except to gain fine control over profiling.
19.PP
20.I Monitor
21is an interface to
22.IR profil (2).
23.I Lowpc
24and
25.I highpc
26are the addresses of two functions;
27.I buffer
28is the address of a (user supplied)
29array of
30.I bufsize
31short integers.
32.I Monitor
33arranges to record a histogram of
34periodically sampled values of the program counter,
35and of counts of calls
36of certain functions, in the buffer.
37The lowest address sampled
38is that of
39.I lowpc
40and the highest is
41just below
42.IR highpc .
43At most
44.I nfunc
45call counts can be kept; only calls of functions
46compiled with the profiling option
47.B \-p
48of
49.IR cc (1)
50are recorded.
51For the results to be significant,
52especially where there are small, heavily
53used routines,
54it is suggested that the buffer be no more
55than a few times smaller than the range
56of locations sampled.
57.PP
58To profile the entire program,
59it is sufficient to use
60.PP
61 extern etext();
62.br
63 ...
64.br
65 monitor((int)2, etext, buf, bufsize, nfunc);
66.PP
67.I Etext
68lies just above all the
69program text, see
70.IR end (3).
71.PP
72To stop execution monitoring and write the results
73on the file
74.I mon.out,
75use
76.PP
77 monitor(0);
78.LP
79then
80.IR prof (1)
81can be used
82to examine the results.
83.SH FILES
84mon.out
85.SH "SEE ALSO"
86prof(1), profil(2), cc(1)