scripts to convert data automatically into CSV file for reading into excel...no addin...
[IRC.git] / Robust / src / Benchmarks / SingleTM / add.java
1 import java.io.*;
2 public class add {
3     public static void main(String args[]) {
4         String filename=args[0];
5         try {
6             BufferedReader br=new BufferedReader(new FileReader(filename));
7             long vals[]=new long[1000];
8             int numvals=0;
9             String nextline=null;
10             while((nextline=br.readLine())!=null) {
11                 long v;
12                 int start=nextline.indexOf("TIME=")+5;
13                 String num=nextline.substring(start, nextline.length());
14                 v=Long.parseLong(num);
15                 vals[numvals++]=v;
16             }
17             long sum=0;
18             for(int i=0;i<numvals;i++) {
19                 sum+=vals[i];
20             }
21             double ave=((double)sum)/numvals;
22             double diff=0;
23             for(int i=0;i<numvals;i++) {
24                 double delta=vals[i]-ave;
25                 diff+=delta*delta;
26             }
27             diff=diff/(numvals-1);
28             double std=Math.sqrt(diff);
29             double err=std/Math.sqrt(numvals);
30             if (args.length==1)
31                 System.out.println(ave);
32             else
33                 System.out.println(err);
34         } catch (Exception e) {
35             e.printStackTrace();
36         }
37     }
38
39
40 }