-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalyzeHeaptrace.mnh
38 lines (37 loc) · 962 Bytes
/
analyzeHeaptrace.mnh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
private cleanline(s)->regex.replace(s,'\$\w+','').trim;
main(inputFile,...)->begin
(inputFile|...).each(file,begin
block:=[];
file.fileLineIterator.each(line,
begin
line=''
? begin
prevBlock:=block;
block:=[];
prevBlock.filter({$s<>''});
end
: begin
line.matches('^Call trace')
? begin
prevBlock:=block;
block:=[cleanline(line)];
prevBlock.filter({$s<>''});
end
: begin
block|=cleanline(line);
void;
end;
end;
end)|[block.filter({$s<>''})];
end,|);
end
.elementFrequency //.each(e,print(e));
.each(e,(e[0,0] orElse '').matches('^Call trace') AND e[0].size>1
? [(e[0].head.split(' ').trailing.softCast)*e[1],e[1],e[0]]
: void)
.sort
.each(e,
begin
print(e[2].head,' x',e[1],' (',e[0],')');
printf(' %s',e[2].tail);
end);