-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestScript2.py
77 lines (65 loc) · 2.63 KB
/
testScript2.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
65
66
67
68
69
70
71
72
73
74
75
import time
import os
import subprocess
import matplotlib.pyplot as plt
from compile import compilepy
import numpy as np
input_files = ["tests/sean2_simple_add.py", "tests/P1/sean2_list8.py", "tests/P1/sean2_list9.py"]# , "tests/P2/simple_function_test.py"]#, "tests/P2/sean2_function_test2.py", "tests/P2/sean2_function5.py"]
greedy = []
ilpAll = []
ilpDe = []
ilpStatic = []
ilpDeSta = []
for input_file in input_files:
print '\n\n\n\n', input_file
start = time.time()
compilepy(input_file, input_file.replace('.py', '.s'), False, (True, True, True, False, True), False, False, 0.5)
end = time.time()
greedy.append(end-start)
print "Greedy compile time:", end-start, "seconds"
#ILP here
start = time.time()
compilepy(input_file, input_file.replace('.py', '.s'), True, (True, True, True, False, True), False, False, 0.5)
end = time.time()
ilpAll.append(end-start)
print "ILP compile time with all optimization:", end-start, "seconds"
start = time.time()
compilepy(input_file, input_file.replace('.py', '.s'), True, (False, True, True, False, True), False, False, 0.5)
end = time.time()
ilpDe.append(end-start)
print "ILP compile time with no de optimiztoin:", end-start, "seconds"
start = time.time()
compilepy(input_file, input_file.replace('.py', '.s'), True, (True, False, True, False, True), False, False, 0.5)
end = time.time()
ilpStatic.append(end-start)
print "ILP compile time with no static optimization:", end-start, "seconds"
start = time.time()
compilepy(input_file, input_file.replace('.py', '.s'), True, (False, False, True, False, True), False, False, 0.5)
end = time.time()
ilpDeSta.append(end-start)
print "ILP compile time with no de, static optimization:", end-start, "seconds"
inputNames = ["Addition.py", "List.py", "Other_List.py"]
for i in range(len(greedy)):
data = [greedy[i], ilpAll[i], ilpDe[i], ilpStatic[i], ilpDeSta[i]]
N = 5
ind = np.arange(N)
width = 0.35
fig, ax = plt.subplots()
rects1 = ax.bar(ind, data, width, color='r')
ax.set_ylabel('Times (seconds)')
ax.set_title(inputNames[i] + " performance")
ax.set_xticks(ind + width / 2)
ax.set_xticklabels(('Greedy', 'ILP All (spill cost)', 'ILP no De (spill cost)', 'ILP no Static (spill cost)', 'ILP None (spill cost)'))
plt.ylim((0, ilpDe[i]*1.25))
def autolabel(rects):
"""
Attach a text label above each bar displaying its height
"""
for rect in rects:
height = rect.get_height()
ax.text(rect.get_x() + rect.get_width()/2., 1.05*height,
'%.3f' % float(height),
ha='center', va='bottom')
autolabel(rects1)
#plt.show()
plt.savefig(str(i) + "perfGraphSpill.png", bbox_inches='tight')