167 lines · 3.5 KB · Text
RawDownload
.TH PROF 1.SH NAMEprof, tprof, kprof \- display profiling data.SH SYNOPSIS.B prof[.B -dr][.I program][.I profile].PP.B tprof.I pid.PP.B kprof.I kernel.I kpdata.SH DESCRIPTION.I Profinterprets files produced automatically by programs loaded using the.B -poption of.IR 2l (1)or other loader.The symbol table in thenamed program file.RL ( 2.outetc., according to.BR $objtype ,by default)is read and correlated with theprofile file.RL ( prof.outby default).For each symbol, the percentageof time (in seconds) spent executing between that symboland the nextis printed (in decreasing order),together with the time spent there andthe number of times that routine was called..PPUnder option.BR -d ,.I profprints the dynamic call graph of the target program,annotating the calls with the time spent in each routineand those it calls, recursively.  The output is indentedtwo spaces for each call, and is formatted as.IP.EXsymbol:time/ncall.EE.LPwhere.I symbolis the entry point of the call,.I timeis in milliseconds,and.I ncallis the number of times that entry point was called at thatpoint in the call graph.  If.I ncallis one, the.B /ncallis elided.Normally recursive calls are compressed to keep the output brief;option.B -rprints the full call graph..PPThe size of the bufferin.I programused to hold the profilingdata, by default 2000 entries,may be controlled by setting the environment variable.B profsizebefore running.IR program .If the buffer fills, subsequent function calls may not be recorded..PPThe profiling code provided by the linker initializes itself to profile the current pid,producing a file called.B prof.\f2pid\fP.If a process forks, only the parent will continue to be profiled.  Forked childrencan cause themselves to be profile by calling.IP.EXprof(fn, arg, entries, what).EE.LPwhich causes the function \f2fn\fP(\f2arg\fP) to be profiled.  When \f2fn\fPreturns .B prof.\f2pid\fPis produced for the current process pid..PPThe environment variable.B proftypecan be set to one of.BR user ,.BR kernel ,.BR elapsed ,or.BR sample ,to profile time measured spent in user mode, time spent in user+kernel mode, or elapsed time,using the cycle counter, or the time in user mode using the kernel's HZ clock.  The cycle counteris currently only available on modern PCs and on the PowerPC.  Default profiling measures usertime, using the cycle counter if it is available..PP.I Tprofis similar to.IR prof ,but is intended for profiling multiprocess programs.It uses the.BI /proc/ pid /profilefile to collect instruction frequency counts for the text image associated with the process,for all processes that share that text.It must be run while the program is still active, since the data is stored with the running program.To enable.I tprofprofiling for a given process,.IP.EXecho profile > /proc/\f2pid\f1/ctl.EE.LPand then, after the program has run for a while, execute.IP.EXtprof \f2pid\f1.EE.LPSince the data collected for.I tprofis based on interrupt-time sampling of the program counter,.I tprofhas no.B -dor.B -roptions..PP.I Kprofis similar to.IR prof ,but presents the data accumulated by the kernelprofiling 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 Kprofhas 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 exec (2),.IR kprof (3)