xref: /inferno-os/module/profile.m (revision 46439007cf417cbd9ac8049bb4122c890097a0fa)
1Profile: module
2{
3	PATH: con "/dis/lib/profile.dis";
4
5	Range: adt{
6		l: int;
7		u: int;
8		f: int;
9		n: cyclic ref Range;
10	};
11
12	Funprof: adt{
13		name: string;
14		# file: string;
15		line: int;
16		count: int;
17		counte: int;
18	};
19
20	Modprof: adt{
21		name: string;
22		path: string;
23		srcpath: string;
24		rawtab: array of (int, int);
25		linetab: array of int;
26		rngtab: array of ref Range;
27		funtab: array of Funprof;
28		total: int;
29		totals: array of int;
30		coverage: int;
31	};
32
33	Prof: adt{
34		mods: list of Modprof;
35		total: int;
36		totals: array of int;
37	};
38
39	Coverage: type list of (string, int, list of (list of (int, int, int), string));
40
41	# constants to or into second arg of show()
42	MODULE: con 1;	# give stats for each module
43	FUNCTION: con 2;	# give stats for each function
44	LINE: con 4;		# give stats for each line
45	VERBOSE: con 8;	# full stats
46	FULLHDR: con 16;	# file:lineno: on each line of output
47	FREQUENCY: con 32;	# show frequency rather than coverage
48
49	init: fn(): int;
50	lasterror: fn(): string;
51	profile: fn(m: string): int;
52	sample: fn(i: int): int;
53	start: fn(): int;
54	stop: fn(): int;
55	stats: fn() : Prof;
56	show: fn(p: Prof, v: int): int;
57	end: fn(): int;
58
59	# coverage profiling specific functions
60
61	cpstart: fn(pid: int): int;
62	cpstats: fn(rec: int, v: int): Prof;
63	cpfstats: fn(v: int): Prof;
64	cpshow: fn(p: Prof, v: int): int;
65
66	coverage: fn(p: Prof, v: int): Coverage;
67
68	# memory profiling specific functions
69
70	MAIN: con 1;
71	HEAP: con 2;
72	IMAGE: con 4;
73
74	memstart: fn(mem: int): int;
75	memstats: fn(): Prof;
76	memshow: fn(p: Prof, v: int): int;
77
78};
79