-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcalc_gmean.py
54 lines (38 loc) · 1.07 KB
/
calc_gmean.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
import matplotlib.pyplot as plt
import numpy as np
plt.rcdefaults()
# get the data into lines array
with open('results.log') as f:
data = f.read()
lines = data.split('\n')
# calculate product of lru_ipc/crc_ipc
prod = 1.0
lines = lines[0:len(lines) - 1]
speedup = {}
for line in lines:
info = line.split()
benchmark = info[0]
lru_ipc = float(info[3])
crc_ipc = float(info[4])
current_speedup = crc_ipc / lru_ipc
speedup[benchmark] = float(current_speedup)
prod = prod * current_speedup
# calculate gmean
gmean = prod**(1.0 / len(lines))
print 'Geometric mean IPC = ' + str(gmean) + "\nSpeedup = " + str((gmean - 1.0) * 100) + "%"
keys = []
values = []
for key in sorted(speedup, key=speedup.get):
values.append(speedup[key])
keys.append(key)
min_y = min(values)
values.append(0.0)
values.append(gmean)
keys.append("")
keys.append("Geometric Mean")
plt.bar(range(len(values)), values, align='center')
plt.xticks(range(len(keys)), keys, rotation=90)
min, max = plt.ylim()
plt.ylim(min_y - 0.1, max)
plt.grid(True, axis='y')
plt.show()