.TH PROF 1
.SH NAME
prof, kprof \- display profiling data
.SH SYNOPSIS
.B prof
[
.B -dr
]
[
.I program
]
[
.I profile
]
.PP
.B kprof
.I kernel
.I kpdata
.SH DESCRIPTION
.I Prof
interprets files produced automatically by programs loaded using the
.B -p
option of
.IR 2l (1)
or other loader.
The symbol table in the
named program file
.RL ( v.out
by default)
is read and correlated with the
profile file
.RL ( prof.out
by default).
For each symbol, the percentage
of time (in seconds) spent executing between that symbol
and the next
is printed (in decreasing order),
together with the time spent there and
the number of times that routine was called.
.PP
Under option
.BR -d ,
.I prof
prints the dynamic call graph of the target program,
annotating the calls with the time spent in each routine
and those it calls, recursively.  The output is indented
two spaces for each call, and is formatted as
.EX
	symbol:time/ncall
.EE
where
.I symbol
is the entry point of the call,
.I time
is in milliseconds,
and
.I ncall
is the number of times that entry point was called at that
point in the call graph.  If
.I ncall
is one, the
.B /ncall
is elided.
Normally recursive calls are compressed to keep the output brief;
option
.B -r
prints the full call graph.
.PP
The size of the buffer
in
.I program
used to hold the profiling
data, by default 2000 entries,
may be controlled by setting the environment variable
.B profsize
before running
.IR program .
If the buffer fills, subsequent function calls may not be recorded.
.PP
.I Kprof
is similar to
.IR prof ,
but presents the data accumulated by the kernel
profiling device,
.IR kprof (3) .
The symbol table file, that of the operating system kernel,
and the data file, typically
.BR /dev/kpdata ,
must be provided.
.I Kprof
has no options and cannot present dynamic data.
.SH SOURCE
.B /sys/src/cmd/prof.c
.br
.B /sys/src/cmd/kprof.c
.SH SEE ALSO
.IR 2l (1),
.IR kprof (3)
