-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpin.py
58 lines (49 loc) · 1.4 KB
/
pin.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
import os
import img2pdf
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
limit = 35
path = 'C://Users//srama//Documents//GitHub//Sameeksha//Results//wordcount_tungsten_studies//'
benchmarks = os.listdir(path)
with PdfPages('./Tool_Output/'+"PinTool_Results"+'.pdf') as pdf:
for b in benchmarks:
for f in os.listdir(path+b):
print(b,f)
file = open(path+b+'//'+f)
data = dict()
colors=['green', 'blue', 'cyan', 'orange', 'black', 'red']
absorb=False
count=0
for line in file:
count+=1
if line.startswith('*'):
absorb = False
break
if(absorb):
line = line[:-1]
if(not line.startswith('#')):
temp = line.split(' ') #.replace(' ',''))
temp[1] = '/'
temp = ' '.join(temp)
temp = temp.replace(' ','')
temp = temp.split('/')
data[int(temp[1])]=temp[0]
if line.startswith('# opcode '):
absorb = True
val = list(data.keys())
val.sort(reverse=True)
val = val[:limit]
n = len(val)
y = [i for i in range(0,n)]
headers = [data[val[i]] for i in range(0,n)]
len(list(data.values()))
list(data.values())[:limit]
plt.clf()
plt.bar(y, val, align='center', alpha=0.5, color=colors, edgecolor='black', width=1.0)
plt.xticks(y, headers,rotation=90)
plt.title(b+'_'+f)
plt.tight_layout()
pdf.savefig()
# plt.show()
file.close()