Charles.Forsyth20060303-partialeea662d19 years agoHistory
225 lines · 6.2 KB · Text
RawDownload
.TH PROFILE 2.SH NAMEprofile \- profiling library.SH SYNOPSIS.EXinclude "profile.m"; profile := load Profile Profile->PATH; Range: adt{    l: int;    u: int;    f: int;    n: cyclic ref Range;}; Funprof: adt{    name: string;    line: int;    count: int;    counte: int;}; Modprof: adt{    name: string;    path: string;    srcpath: string;    rawtab: array of (int, int);    linetab: array of int;    rngtab: array of ref Range;    funtab: array of Funprof;    total: int;    totals: array of int;    covered: int;}; Prof: adt{    mods: list of Modprof;    total: int;    totals: array of int;}; Coverage: type list of (string, int, list of (list of (int, int, byte), string)); MODULE: con 1;	# give stats for each moduleFUNCTION: con 2;	# give stats for each functionLINE: con 4;	# give stats for each lineVERBOSE: con 8;	# full statsFULLHDR: con 16;	# file:lineno: on each line of outputFREQUENCY: con 32;	# show frequency rather than coverage init: fn(): int;profile: fn(m: string): int;sample: fn(i: int): int;start: fn(): int;stop: fn(): int;stats: fn() : Prof;show: fn(p: Prof, v: int): int;end: fn(): int; # coverage profiling specific functions cpstart: fn(pid: int): int;cpstats: fn(rec: int, v: int): Prof;cpfstats: fn(v: int): Prof;cpshow: fn(p: Prof, v: int): int; coverage: fn(p: Prof, v: int): Coverage; # memory profiling specific functions memstart: fn(): int;memstats: fn(): Prof;memshow: fn(p: Prof, v: int): int; lasterror: fn(): string;.EE.SH DESCRIPTION.B Profileprovides an interface to the kernel profile device. It contains routines to start and stopprofiling, to gather profiling statistics and to display these statistics in relation to therelevant limbo source code. All of these routines apart from.B lasterrorreturn a negative integer if an error occurred during their execution. Once thishappens, a call to.B lasterrorwill give the error message..PP.B initinitializes the module and binds the kernel profile device onto the /prof directory.It should be called before any other functions in this module..PP.B profiletakes a module name or a path name as its argument and indicates a module to be profiled.Repeated calls of this function allow a number of modules to be profiled together.In the absence of any calls to this routine, the profile device profiles all modulesloaded by the kernel..PP.B samplesets the sampling interval of the profiling. The argument is in ms. The default valuein the profile device is 100ms..PP.B startstarts profiling..PP.B stopstops profiling..PP.B statsreturns profiling statistics. It is recommended that this is called once profiling hasbeen stopped, otherwise the results may be slightly inaccurate. It returns an adtof type .B Prof.Its first field.B modsis a list of profile statistics for each module under profile.Its second field .B total is the number of samples made altogether. The statistics for each module arerepresented in the.B Modprofadt. Its fields are.TP 10n.B nameThe name of the module..TP 10n.B pathThe path of the module's corresponding dis file..TP 10n.B srcpathThe path of the module's corresponding source file..TP 10n.B linetabThe line frequency count table. The number of samples made on a particular line ofthe above source file is found by indexing this table..TP 10n.B funtabThe function frequency count table. This array of.B Funprofadt gives the name, line number and number of samples made for each function inthe above source file..TP 10n.B totalThe total number of samples made in this module..PP.B statswill ignore modules if it fails to locate the symbol (.sbl) file for a particular dis file..PP.B showsimply prints out the profile information returned by.B stats.For each module it will print out either the line number statistics or the functionstatistics or both. The former gives the line number, percentage of time spent onthis line and the source code for each line in the source file. The latter gives theline number, function name and percentage of time spent in this function for eachfunction in the source file. The amount of output can be controlled by the secondargument to.B show.The following should be ored together in the required combination to get thedesired effect..PP.TP 10n.B FUNCTIONPrint the function table..TP 10n.B LINEPrint the line number table..TP 10n.B VERBOSENormally lines and functions are not shown if the sample frequency for them iszero. This option prevents this..TP 10n.B FULLHDRPrints the file name as well as the line number in a form that can be selected in.B acmeto show that particular line in a window..PP.B showwill ignore modules if it fails to locate the source (.b) file for a particular dis file..PP.B endends the profiling session. This should be called when all statistics have been gathered in order to clean up the device profile's data structures..PPIn order to support coverage profiling as well the following new routines areprovided..PP.B cpstartStart coverage profiling on the process whose pid is given..PP.B cpstatsReturns coverage profiling statistics from the profile device. If the first argument istrue, the raw results will be stored in a profile file whose name is <file>.prf where<file> is the prefix of the corresponding dis file..PP.B cpfstatsReturns coverage profiling statistics from any saved profile files..PP.B cpshowShows the coverage profiling statistics..PP.B coverageGiven the coverage profiler statistics this returns the list of modules profiled. Each modulehas a name, a boolean indicating whether all instructions in the module were executed and alist of lines. Each line consists of a list of ranges and the source code.The list of ranges contains the character positions on the line of code corresponding to instructions that were not executed and an indicator of whetherpartial execution was performed..PPFor the further support of memory profiling the following routines are available..PP.B memstartStart memory profiling..PP.B memstatsReturn the memory profile statisics..PP.B memshowSend memory profile statistics to standard output..PP.SH SOURCE.B /module/profile.m.br.B /appl/lib/profile.b.SH SEE ALSO.IR prof (3)