1 # R script that produces histograms from benchmarked values
3 # Can be called from the bash script with the following code:
4 # export R_INPUT=$inputfile
5 # export R_OUTPUT=$outputfile
6 # R CMD BATCH $this_script.R
8 # Use functions from bench.h to benchmark execution time of the desired block,
9 # then Rhist.R script to read all timings and produce histograms
10 # and finally inject.h to inject values instead of executing block
13 inputfile<-Sys.getenv("R_INPUT")
14 outputfile<-Sys.getenv("R_OUTPUT")
16 df<-read.table(inputfile,header=F)
18 names(df)<-c("NAME","TIME")
21 for(i in unique(NAME))
23 vector1<-df[NAME==i,2]
26 cat(i, file = outputfile, sep = "\t", append = TRUE)
27 cat(" ", file = outputfile, sep = "\t", append = TRUE)
28 cat(sprintf("%.8f", mean(vector1)), file =outputfile, sep = "\t ", append = TRUE)
29 cat("\t", file = outputfile, append = TRUE)
30 cat(length(h$breaks), file = outputfile, append = TRUE)
31 cat("\t", file = outputfile, append = TRUE)
32 cat(sprintf("%.8f", h$breaks), file = outputfile, sep = " \t", append = TRUE)
33 cat("\t", file = outputfile, append = TRUE)
34 h$density = h$counts/sum(h$counts)
35 cat(sprintf("%.14f", h$density), file = outputfile, sep = " \t", append = TRUE)
36 cat("\n", file = outputfile, append = TRUE)