-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdouble_pooling_constant_plot.py
More file actions
150 lines (109 loc) · 3.9 KB
/
Copy pathdouble_pooling_constant_plot.py
File metadata and controls
150 lines (109 loc) · 3.9 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import random
def double_pooling(batch_size,data):
# create sub_batches
test_numbers_in_sub_batch=0
double_batches=[]
for i in range(0,batch_size+1):
double_batches.append([])
counter=0
for i in range(0,batch_size):
j=i+1
while(len(double_batches[i])<batch_size):
double_batches[i].append(data[counter])
double_batches[j].append(data[counter])
counter=counter+1
j=j+1
#print(double_batches)
test_numbers_in_sub_batch=test_numbers_in_sub_batch+batch_size+1
result=[]
for sub_double_batch in double_batches:
result.append(run_batch(sub_double_batch))
faild_builds=0
#print(result)
for flag in result:
if(flag==False):
faild_builds=faild_builds+1
if(faild_builds<=2):
return test_numbers_in_sub_batch
else:
num=faild_builds-1
#print(num)
addition=(num*(num+1)/2)
return (test_numbers_in_sub_batch+addition)
def run_batch(batch):
for element in batch:
if element==False:
return False
break
return True
def assign_pooling(batch_size,data):
total_test=0
sub_batch_size=int((batch_size*(batch_size+1))/2)
batch_numbers=(int)(len(data)/sub_batch_size)
counter=0
for i in range(0,batch_numbers):
upper_bound=(counter+sub_batch_size)
sub_batch=data[counter:upper_bound]
a=double_pooling(batch_size,sub_batch)
total_test=total_test+a
#print(a,"salam")
counter=counter+sub_batch_size
return total_test
import numpy as np
import pandas as pd
import math
import random
import os
#data=data[236:] #ruby--ruby.csv
#data=data[6:] #puppetlabs--puppet.csv
#data=data[7:] #rspec--rspec-core.csv
#data=data[94:] #opal--opal.csv
#print(1-(assign_pooling(7,data)/len(data)))
def run_simulation():
project_names = ['vagrant', 'rails', 'okhttp', 'gradle', 'cloudify', 'puppet', 'opal', 'ownlcloud', 'graylog2',
'ruby', 'metasploit', 'rspec']
savings_for_pejects = []
projects = (os.listdir("./data/extracted_project_travis"))
colors_name = ["green", "gold", "orange", "gray", "black", "pink", "lime", "tan", "red", "blue", "purple",
"darksalmon"]
for i in range(0, len(projects)):
savings_for_pejects.append([])
global data
projects = (os.listdir("./data/extracted_project_travis"))
for size in range(2, 21):
print(size)
for j in range(0,len(projects)):
project_path = './data/extracted_project_travis/' + projects[j]
data = pd.read_csv(project_path)
if (projects[j] == 'ruby.csv'):
data = data[data.git_branch == "trunk"]
else:
data = data[data.git_branch == "master"]
data = data.build_successful
data = pd.Series.tolist(data)
data = data[100:]
# test_number=1 - (assign_pooling(size, data) / len(data))
savings_for_pejects[j].append(1 - (assign_pooling(size, data) / len(data)))
print(savings_for_pejects)
for lis in savings_for_pejects:
lis.insert(0, 0)
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
import matplotlib.pyplot as plt
yaxis = list(range(1, 20 + 1))
axes = plt.axes()
axes.set_xticks([2, 4, 6, 8, 10, 12, 14, 16, 18, 20])
print(len(savings_for_pejects[0]))
average = []
for i in range(0, len(savings_for_pejects[0])):
sum = 0
for lis in savings_for_pejects:
sum += lis[i]
average.append(sum / len(savings_for_pejects))
for i in range(0, len(savings_for_pejects)):
plt.plot(yaxis, savings_for_pejects[i], colors_name[i], label=project_names[i])
plt.xlabel('Batch Size')
plt.ylabel('Saving%')
plt.legend()
plt.show()
print(average)
run_simulation()