Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge tag 'v3_9_90' into hypervisor
[simgrid.git] / contrib / benchmarking_code_block / Rhist.R
1 # R script that produces histograms from benchmarked values
2
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
7
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
11
12   
13 inputfile<-Sys.getenv("R_INPUT")
14 outputfile<-Sys.getenv("R_OUTPUT")
15
16 df<-read.table(inputfile,header=F)
17 df<-df[,c(1,4)]
18 names(df)<-c("NAME","TIME")
19 attach(df)
20
21 for(i in unique(NAME))
22 {
23   vector1<-df[NAME==i,2]
24   h<-hist(vector1)
25   
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)
37 }