-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDataCollection.java
350 lines (295 loc) · 11.5 KB
/
DataCollection.java
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
public class DataCollection {
/*
I/System.out( 1759): Block Starts: 1434479186084
I/System.out( 1759): Start counter: 1
D/audio_hw_primary( 190): out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
I/System.out( 1759): End counter: 0 1434479186102
I/System.out( 1759): Block Ends: 1434479186102
*/
public static void main(String[] args) throws IOException {
collectInfo(args[0]);
System.out.println("-----------Results in section 6.4-----------");
System.out.println("See the PeformanceEvaluation.ods\n");
collectTime(args[1]);
}
public static void collectInfo(String file) throws IOException
{
BufferedReader br = new BufferedReader(new FileReader(new File(file)));
String line = br.readLine();
String app = null;
int numAHP = 0;
int numHP = 0;
int numSAHP = 0;
int numDBL = 0;
int numAHPRelatedToLock = 0;
Map<Integer,Integer> length = new HashMap<>();
Map<Integer,Integer> lengthAHP = new HashMap<>();
int totalAHPCallChain = 0;
int maxAHPCallChain = 0;
List<Integer> relevantCode = new ArrayList<>();
double pruneCCGTotal = 0;
int numApps = 0;
int numDBApps = 0;
int numHPApps = 0;
int numAHPApps = 0;
int currentAHP = 0;
int currentSAHP = 0;
int currentHP = 0;
List<Integer> totalCode = new ArrayList<>();
List<Integer> AHPNums = new ArrayList<>();
boolean isAHP = false;
while (line != null) {
if(line.startsWith("/App"))
{
app = line;
numApps++;
/*
if(numApps == 90)
{
System.out.println(line);
break;
}
*/
}
else if(line.startsWith("Exist Repair:true"))
numAHPApps++;
else if(line.startsWith("Exist Opp:true"))
numHPApps++;
else if(line.startsWith("Exist SQL in User Code:true"))
numDBApps++;
else if(line.startsWith("Num of HP"))
{
currentHP = Integer.parseInt(line.split(":")[1]);
numHP += Integer.parseInt(line.split(":")[1]);
}
else if(line.startsWith("Num of AHP"))
{
numAHP += Integer.parseInt(line.split(":")[1]);
currentAHP = Integer.parseInt(line.split(":")[1]);
if(currentAHP!=0)
AHPNums.add(currentAHP);
// System.out.println(currentAHP);
}
else if(line.startsWith("Num of in scope HP"))
{
numSAHP += Integer.parseInt(line.split(":")[1]);
}
else if(line.startsWith("Num of DB in loop"))
numDBL += Integer.parseInt(line.split(":")[1]);
else if(line.startsWith("@HP@"))
isAHP = false;
else if(line.startsWith("@AHP@"))
isAHP = true;
else if(line.startsWith("Target loop nests a lock or is nested in a lock:true"))
{
if(isAHP&&!app.contains("/App562/"))
numAHPRelatedToLock+=1;
}
else if(line.startsWith("Line of target bytecodes"))
{
int count = Integer.parseInt(line.split(":")[1]);
relevantCode.add(count);
}
else if(line.startsWith("CCG prune out code"))
{
if(!line.contains("NaN"))
{
double percent = Double.parseDouble(line.split(":")[1].replaceAll("%", ""));
pruneCCGTotal += percent;
}
}
else if(line.startsWith("Num of bytecodes in program:"))
{
totalCode.add(Integer.parseInt(line.split(":")[1]));
}
else if(line.startsWith("Length of call chain between db operation and call graph entry"))
{
if(isAHP&&!app.contains("/App562/"))
{
int chain = Integer.parseInt(line.split(":")[1]);
totalAHPCallChain += chain;
if(chain > maxAHPCallChain)
maxAHPCallChain = chain;
}
}
else if(line.startsWith("Length of call chain between db operation and loop header"))
{
//do not include the outlier
if(!app.contains("/App562/"))
{
int l = Integer.parseInt(line.split(":")[1]);
if(length.containsKey(l))
length.put(l, length.get(l)+1);
else
length.put(l, 1);
if(isAHP)
{
int l1 = Integer.parseInt(line.split(":")[1]);
if(lengthAHP.containsKey(l1))
lengthAHP.put(l1, lengthAHP.get(l1)+1);
else
lengthAHP.put(l1, 1);
}
}
}
line = br.readLine();
}
br.close();
//App 69 has 20134 relevant byte code
int largerThanApp69 = 0;
for(int i = 0; i < relevantCode.size(); i++)
{
if(relevantCode.get(i) > 20134)
largerThanApp69++;
}
Collections.sort(totalCode);
int totalApp = 0;
int[] dis = {1000,10000,100000};
Integer [] disNum = new Integer[4];
for(int i = 0; i < 4; i++)
disNum[i] = 0;
for(int i = 0; i < totalCode.size();i++)
{
int size = totalCode.get(i);
if(size!=0)
totalApp++;
for(int j = 0; j < 2; j++)
{
if(size >= dis[j] && size < dis[j+1])
disNum[j+1] ++;
}
if(size < dis[0])
disNum[0]++;
if(size >= dis[2])
disNum[3]++;
}
System.out.println("-----------Relevant bytecode in section 4.2 and section 6.5-----------");
System.out.println("CCG prune out in average:"+pruneCCGTotal*1.0/totalApp+"%");
System.out.println("Relevant Bytecode larger than App69:"+largerThanApp69*1.0/relevantCode.size()*100+"%");
System.out.println();
System.out.println("-----------Results in section 6.2-----------");
System.out.println("Distribution of bytecode in program 0-10000,10000-100000, 100000-inf:"
+(disNum[0]+disNum[1])*100/totalApp+"%,"+(disNum[2])*100/totalApp+"%,"+(disNum[3])*100/totalApp+"%");
System.out.println();
System.out.println("-----------Results in section 6.3-----------");
System.out.println("Total num of apps:"+numApps+"\n"
+ "Total num of apps with db operations:"+numDBApps+"\n"
+ "Total num of apps with ARAT:"+numAHPApps +"\n"
+ "Percentage of apps with ARAT over all apps:"+numAHPApps*100.0/numApps+"%\n"
+ "Percentage of apps with ARAT over apps with db operations:"+numAHPApps*100.0/numDBApps+"%");
System.out.println("Num of ARAT:"+numAHP+" after excluding outlier:"+(numAHP-4220));
System.out.println("Average number of ARAT:"+(numAHP-4220)*1.0/(numAHPApps-1));
Collections.sort(AHPNums);
System.out.println("Median number of ARAT:"+AHPNums.get(numAHPApps/2));
System.out.println("ARAT with loop related to locks:"+numAHPRelatedToLock+" Percentage:"+numAHPRelatedToLock*1.0/(numAHP-4220)*100+"%");
System.out.println("Percentage of in-scope RATs that may cause deadlock:"
+ (numSAHP-numAHP)*1.0/(numSAHP-4220)*100+"%");
//outlier
//lengthAHP.put(2, lengthAHP.get(2)-4220);
int total = 0;
int zero = length.get(0);
int totalAHP = 0;
int zeroAHP = lengthAHP.get(0);
for(Entry<Integer,Integer> en : lengthAHP.entrySet())
{
totalAHP += en.getValue();
}
System.out.println("Call path length between db operation and loop header:"+lengthAHP);
System.out.println("AHP with call path length >=1:"+(1-zeroAHP*1.0/totalAHP)*100+"%");
System.out.println("Average call path length between db operation and call graph entry:"+totalAHPCallChain*1.0/(numAHP-4220));
System.out.println("Max call path length between db operation and call graph entry:"+maxAHPCallChain);
System.out.println();
}
public static void collectTime(String path) throws IOException
{
int times = 15;
BufferedReader br = new BufferedReader(new FileReader(path));
Map<String,Double[]> map = new HashMap<>();
String line = br.readLine();
String appName = null;
while (line != null) {
// if(line.contains("Batch"))
// System.out.println(listOfFiles[i].getName());
if(line.startsWith("/App"))
{
appName = line;
if(map.get(appName)==null)
{
Double[] d = new Double[4];
Arrays.fill(d, 0.0);
map.put(appName, d);
}
}
else if(line.startsWith("Soot:"))
{
int time = Integer.parseInt(line.split(":")[1].replaceAll("ms", ""));
map.get(appName)[0] += time;
}
else if(line.startsWith("Analysis:"))
{
int time = Integer.parseInt(line.split(":")[1].replaceAll("ms", ""));
map.get(appName)[1] += time;
}
else if(line.startsWith("Rewrite:"))
{
int time = Integer.parseInt(line.split(":")[1].replaceAll("ms", ""));
map.get(appName)[2] += time;
}
else if(line.startsWith("Total:"))
{
int time = Integer.parseInt(line.split(":")[1].replaceAll("ms", ""));
map.get(appName)[3] += time;
}
line = br.readLine();
}
br.close();
for(String app : map.keySet())
{
//System.out.println(app);
for(int i = 0; i < 4; i++)
{
//System.out.println(map.get(app)[i]);
map.get(app)[i] = map.get(app)[i] * 1.0 / times;
}
}
double total = 0;
double sootPercent = 0;
double all[] = new double[6];
int j = 0;
System.out.println("-----------Results in section 6.5-----------");
for(String app : map.keySet())
{
System.out.println(app);
System.out.println("Soot:"+(map.get(app)[0]/1000)+"s");
System.out.println("Analysis:"+(map.get(app)[1]/1000)+"s");
System.out.println("Rewrite:"+(map.get(app)[2]/1000)+"s");
System.out.println("Total:"+(map.get(app)[3]/1000)+"s");
System.out.println();
all[j++] = map.get(app)[3];
total += map.get(app)[3];
sootPercent += map.get(app)[0] / map.get(app)[3];
}
Arrays.sort(all);
System.out.println("Min Total:"+(int)(all[0]/1000)+"s");
System.out.println("Max Total:"+(int)(all[map.keySet().size()-1]/1000)+"s");
System.out.println("Median Total:"+(int)((all[2]+all[3])/2000)+"s");
System.out.println("Average Total:"+(int)(total/1000)/map.keySet().size()+"s");
System.out.println("Average Percentage of time spent on Soot:"+(int)(sootPercent*100.0)/map.keySet().size()+"%");
}
}