-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprogress.py
64 lines (53 loc) · 1.54 KB
/
progress.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
from dataclasses import dataclass
import shutil
import glob
import os
@dataclass
class Function():
name: str
size: int
def __lt__(self, other):
return self.size < other.size
def get_size(path):
f = open(path, 'r')
lines = f.readlines()
f.close()
name = os.path.basename(file).split('.')[0]
inst = 0
for line in lines:
if ('glabel ' + name) in line:
inst = 0
if line.startswith('/*'):
inst += 1
return inst
dirs = glob.glob("nonmatchings/src/code0/*")
dirs += glob.glob("nonmatchings/src/code1/*")
dirs += glob.glob("nonmatchings/gen/code0/*")
shutil.rmtree('stats', ignore_errors=True)
os.mkdir('stats')
os.mkdir('stats/code0')
os.mkdir('stats/code1')
all_func = []
for dir in dirs:
func = []
asm_files = [y for x in os.walk(dir) for y in glob.glob(os.path.join(x[0], '*.s'))]
for file in asm_files:
name = os.path.basename(file).split('.')[0]
if name.startswith('D_'):
continue
func.append(Function(name, get_size(file)))
all_func += func
func.sort()
parent1 = os.path.split(dir)
parent2 = os.path.split(parent1[0])
path = os.path.join('stats', parent2[1], parent1[1]) + '.csv'
f = open(path, 'w')
for fu in func:
f.write(fu.name+';'+str(fu.size)+'\n')
f.close()
all_func.sort()
f = open(os.path.join('stats', 'all.csv'), 'w')
for fu in all_func:
f.write(fu.name+';'+str(fu.size)+'\n')
f.close()