adding a test case
[IRC.git] / Robust / TransSim / log / analyze.java
1 import java.io.*;
2
3 class analyze {
4   public static int NUM=30;
5   public static void main(String files[]) throws Exception {
6     int M=files.length-1;
7     String[][] names=new String[NUM][M];
8     long[][] times=new long[NUM][M];
9     long[][] aborts=new long[NUM][M];
10     long[][] commits=new long[NUM][M];
11     long[][] stalltime=new long[NUM][M];
12     long[][] backofftime=new long[NUM][M];
13     long[][] abortedtime=new long[NUM][M];
14     for(int i=0;i<(files.length-1);i++) {
15       BufferedReader br=new BufferedReader(new FileReader(files[i+1]));
16       String x;
17       int count=0;
18       while((x=br.readLine())!=null) {
19         int index=x.indexOf('=');
20         names[count][i]=x.substring(0, index);
21         String n=x.substring(index+1, x.length());
22         times[count][i]=Long.parseLong(n);
23         {
24           x=br.readLine();
25           int i1=x.indexOf('=');
26           int i2=x.indexOf(' ');
27           int i3=x.indexOf('=', i2);
28           String saborts=x.substring(i1+1, i2);
29           String scommits=x.substring(i3+1, x.length());
30           aborts[count][i]=Long.parseLong(saborts);
31           commits[count][i]=Long.parseLong(scommits);
32         }
33         {
34           x=br.readLine();
35           int i1=x.indexOf('=');
36           int i2=x.indexOf(' ');
37           int i3=x.indexOf('=', i2);
38           String stall=x.substring(i1+1, i2);
39           String backoff=x.substring(i3+1, x.length());
40           stalltime[count][i]=Long.parseLong(stall)/(2<<i);
41           backofftime[count][i]=Long.parseLong(backoff)/(2<<i);
42         }
43
44         {
45           x=br.readLine();
46           int i1=x.indexOf('=');
47           String abortedt=x.substring(i1+1, x.length());
48           abortedtime[count][i]=Long.parseLong(abortedt)/(2<<i);
49         }
50
51         count++;
52       }
53     }
54     String names2[]={"Lazy", "Fast", "Aggressive", "Suicide", "Timestamp", "Random", "Karma", "Polite", "Eruption", "AggressiveTime", "Fixed", "AggressiveFixed"};
55     if (files[0].equals("combined")) {
56       for(int j=0;j<M;j++) {
57         int numthreads=2<<j;
58         FileWriter fw=new FileWriter("file"+numthreads+".dat");
59         fw.write("version aborttime stalltime backofftime baseline\n");
60         for(int i=0;i<names2.length;i++) {
61           long totaltime=times[i][j];
62           long abortt=abortedtime[i][j];
63           long stallt=stalltime[i][j];
64           long backofft=backofftime[i][j];
65           long baset=totaltime-abortt-stallt-backofft;
66           fw.write(names2[i]+" "+abortt+" "+stallt+" "+backofft+" "+baset+"\n");
67         }
68         fw.close();
69       }
70     } else {
71       /* Do individual printing. */
72       System.out.print("X");
73       for(int i=0;i<names2.length;i++) {
74         System.out.print(" "+names2[i]);
75       }
76       System.out.println("");
77       int x=2;
78       for(int j=0;j<M;j++) {
79         System.out.print(x);x*=2;
80         for(int i=0;names[i][0]!=null;i++) {
81           if (files[0].equals("time")) {
82             System.out.print(" "+times[i][j]);
83           } else if (files[0].equals("abortpercent")) {
84             double percent=((double)aborts[i][j])/((double)(commits[i][j]+aborts[i][j]));
85             System.out.print(" "+percent);
86           } else if (files[0].equals("aborttime")) {
87             System.out.print(" "+abortedtime[i][j]);
88           } else if (files[0].equals("stalltime")) {
89             System.out.print(" "+stalltime[i][j]);
90           } else if (files[0].equals("backofftime")) {
91             System.out.print(" "+backofftime[i][j]);
92           }
93         }
94         System.out.println("");
95       }
96     }
97   }
98 }