import java.io.*;
public class add {
public static void main(String args[]) {
- String filename=args[0];
- try {
- BufferedReader br=new BufferedReader(new FileReader(filename));
- long vals[]=new long[1000];
- int numvals=0;
- String nextline=null;
- while((nextline=br.readLine())!=null) {
- long v;
- int start=nextline.indexOf("TIME=")+5;
- String num=nextline.substring(start, nextline.length());
- v=Long.parseLong(num);
- vals[numvals++]=v;
- }
- long sum=0;
- for(int i=0;i<numvals;i++) {
- sum+=vals[i];
- }
- double ave=((double)sum)/numvals;
- double diff=0;
- for(int i=0;i<numvals;i++) {
- double delta=vals[i]-ave;
- diff+=delta*delta;
- }
- diff=diff/(numvals-1);
- double std=Math.sqrt(diff);
- double err=std/Math.sqrt(numvals);
- if (args.length==1)
- System.out.println(ave);
- else
- System.out.println(err);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ int ii=0;
+ boolean outputerr=false;
+ boolean normalize=false;
+ double norma=0.0;
+ for(;ii<args.length;ii++) {
+ if (args[ii].equals("-err"))
+ outputerr=true;
+ else if (args[ii].equals("-norm")) {
+ normalize=true;
+ ii++;
+ norma=Double.parseDouble(args[ii]);
+ } else
+ break;
+ }
+ String filename=args[ii];
+ try {
+ BufferedReader br=new BufferedReader(new FileReader(filename));
+ double vals[]=new double[1000];
+ int numvals=0;
+ String nextline=null;
+ while((nextline=br.readLine())!=null) {
+ double v;
+ int start=nextline.indexOf("TIME=")+5;
+ String num=nextline.substring(start, nextline.length());
+ v=Double.parseDouble(num);
+ if (normalize)
+ v=norma/v;
+ vals[numvals++]=v;
+ }
+ double sum=0;
+ for(int i=0;i<numvals;i++) {
+ sum+=vals[i];
+ }
+ double ave=((double)sum)/numvals;
+ double diff=0;
+ for(int i=0;i<numvals;i++) {
+ double delta=vals[i]-ave;
+ diff+=delta*delta;
+ }
+ diff=diff/(numvals-1);
+ double std=Math.sqrt(diff);
+ double err=std/Math.sqrt(numvals);
+ if (!outputerr)
+ System.out.println(ave);
+ else
+ System.out.println(err);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
\ No newline at end of file
#!/bin/bash
for bm in KMeans.bin Labyrinth.bin SSCA2.bin Genome.bin Vacation.bin yada.bin Intruder.bin Bayes.bin
do
-echo Benchmark $bm >> spreadsheet
-echo type, 1, 2, 4, 8 >> spreadsheet
-for type in FIS FISAR DEB OPTSTM LOCK DV HYDV
+echo $bm FIS FISAR DEB OPSTM DV HYDV > ${bm}_spreadsheet.dat
+cat log/${bm}_1_LOCK_* | grep TIME= > tmpfile
+base=`java add tmpfile`
+for num in 1 2 4 8
do
-line=$type
+line=""
stddevline=""
-for num in 1 2 4 8
+for type in FIS FISAR DEB OPTSTM DV HYDV
do
cat log/${bm}_${num}_${type}_* | grep TIME= > tmpfile
-ave=`java add tmpfile`
-stddev=`java add tmpfile stddev`
-line="$line, $ave"
+ave=`java add -norm $base tmpfile`
+stddev=`java add -err tmpfile`
+line="$line $ave"
stddevline="$stddevline, $stddev"
done
-echo ${line}${stddevline} >> spreadsheet
+echo ${num} ${line} ${stddevline} >> ${bm}_spreadsheet.dat
done
+echo set bar 1.000000 > plot_${bm}.txt
+echo set boxwidth 0.9 absolute >> plot_${bm}.txt
+echo set style fill pattern 0.00 border -1 >> plot_${bm}.txt
+echo set style rectangle back fc lt -3 fillstyle solid 1.00 border -1 >> plot_${bm}.txt
+echo set key inside left top vertical Right noreverse enhanced autotitles columnhead nobox >> plot_${bm}.txt
+echo set style histogram clustered gap 2 title offset character 0, 0, 0 >> plot_${bm}.txt
+echo set datafile missing \'-\' >> plot_${bm}.txt
+echo set style data histograms >> plot_${bm}.txt
+echo set xtics border in scale 1,0.5 nomirror rotate by -45 offset character 0, 0, 0 >> plot_${bm}.txt
+echo set xtics norangelimit >> plot_${bm}.txt
+echo set xrange [-.7:3.7]
+echo set ylabel offset character 0, 0, 0 font \"\" textcolor lt -1 rotate by 90 >> plot_${bm}.txt
+echo set y2label offset character 0, 0, 0 font \"\" textcolor lt -1 rotate by 90 >> plot_${bm}.txt
+echo set yrange [ 0 : 8 ] noreverse nowriteback >> plot_${bm}.txt
+echo set cblabel offset character 0, 0, 0 font \"\" textcolor lt -1 rotate by 90 >> plot_${bm}.txt
+echo set locale \"C\" >> plot_${bm}.txt
+echo plot \'${bm}_spreadsheet.dat\' using 2:xticlabels\(1\) ti col, \'\' u 3 ti col, \'\' u 4 ti col, \'\' u 5 ti col, \'\' u 6 ti col, \'\' u 7 ti col >> plot_${bm}.txt
+echo pause -1 >> plot_${bm}.txt
done
\ No newline at end of file