1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
require(tikzDevice)
source("../../basic_functions.R")
tex_file = "wt.tex"
tc_config <- readConfig("../test_case.config",c("TC_ID","PATH","LATEX_NAME","URL","TC_TYPE"))
open_tikz <- function( file_name ){
tikz(file_name, width = 5.5, height = 7.5 , standAlone = F)
}
x_for_bar<-function(value){
c(0,0,value,value)
}
y_for_bar<-function(offset){
c(offset,offset+0.4,offset+0.4,offset)
}
#Method which plots the size figure
plot_size_figure <-function(data,heading,ylab=F){
#set margin
par(mar=c(3,2,3,0))
if(ylab){
par(mar=c(3,10,3,0))
}
plot(c(),c(),ylim=c(0,(length(data)*0.5)+0.2),xlim=c(0,max(101,(max(data)+1))),xlab="",ylab="",xaxt="n",yaxt="n")
#label y-axis
if(ylab){
axis( 2, at =seq(0.3,(length(data)*0.5)+0.2,0.5), label=colnames(data),las=1)
}
#label x-axis
axis(1)
mtext("Size relative to original file size", side=1, line=2)
#draw bars
offset=0.1
for(time in data){
polygon( x_for_bar(time),y_for_bar(offset), border=NA, col="grey")
offset=offset+0.5
}
#abline(v=c(axis(1)/2,max(axis(1)/2)+axis(1)/2), col="gray")
abline(v=c(axis(1),axis(1)+(axis(1)[2]-axis(1)[1])/2),col="gray")
abline(v=100, col="red")
draw_figure_heading(heading)
}
#Method which plots the a time figure
plot_time_figure <-function(data,heading,ylab=T,xlab=T,constructor=F,xmax=max(data)){
#set margin
par(mar=c(3,2,2,0))
if(ylab){
par(mar=c(3,10,2,0))
}
plot(c(),c(),ylim=c(0,(length(data)*0.5)+0.2),xlim=c(0,(xmax*1.02)),xlab="",ylab="",xaxt="n",yaxt="n")
#label y-axis
if(ylab){
axis( 2, at =seq(0.3,(length(data)*0.5)+0.2,0.5), label=colnames(data),las=1)
}
#label x-axis
axis(1)
abline(v=c(axis(1),axis(1)+(axis(1)[2]-axis(1)[1])/2),col="gray")
if(xlab){
mtext("Time in microseconds", side=1, line=2)
}
if(constructor){
mtext("Time in seconds", side=1, line=2)
}
#draw bars
offset=0.1
for(time in data){
polygon( x_for_bar(time),y_for_bar(offset), border=NA, col="grey")
offset=offset+0.5
}
draw_figure_heading(heading)
}
#read header
tex_doc <- paste(readLines("wt-header.tex"),collapse="\n")
tex_doc<-paste(tex_doc,"\\section{Result of the Wavelet Tree benchmark}")
maindata <- data_frame_from_key_value_pairs( "../results/all.txt" )
#create two pages for each test case
#for(tc in tc_config[['TC_ID']]){
for(tc in unique(maindata$TC_ID)){
data<-maindata[maindata$TC_ID==tc,]
id <-data[['WT_TEX_NAME']]
xmax<-max(data[c('access_time','rank_time','select_time','inverse_select_time','lex_count_time','lex_smaller_count_time')])
#first page start
fig_name <- paste("fig-page1-",tc,".tex",sep="")
tex_doc<-paste(tex_doc,"\\subsection{Test case: {\\sc ",data[['TC_TEX_NAME']],"}}")
open_tikz( fig_name )
layout(matrix(c(1,2,3,4,5,6), 3, 2, byrow = TRUE),
widths=c(1.35,1), heights=c(1,1,1))
#access-plot
a <-data['access_time']
rownames(a)<-id
plot_time_figure(t(a),"\\tt{access}",xlab=F,xmax=xmax)
#rank-plot
rank <-data['rank_time']
rownames(rank)<-id
plot_time_figure(t(rank),"\\tt{rank}",ylab=F,xlab=F,xmax=xmax)
#select-plot
s <-data['select_time']
rownames(s)<-id
plot_time_figure(t(s),"\\tt{select}",xlab=F,xmax=xmax)
#inverse-select-plot
is <-data['inverse_select_time']
rownames(is)<-id
plot_time_figure(t(is),"\\tt{inverse\\_select}",xlab=F,ylab=F,xmax=xmax)
#lex-count-plot
lc <-data['lex_count_time']
rownames(lc)<-id
plot_time_figure(t(lc),"\\tt{lex\\_count}",xmax=xmax)
#lex-smaller-count-plot
lsc <-data['lex_smaller_count_time']
rownames(lsc)<-id
plot_time_figure(t(lsc),"\\tt{lex\\_smaller\\_count}",ylab=F,xmax=xmax)
old<-par()
dev.off()
tex_doc <- paste(tex_doc,"\\begin{figure}[H]
\\input{",fig_name,"}
\\end{figure}")
#first page end
#second page start
fig_name <- paste("fig-page2-",tc,".tex",sep="")
open_tikz( fig_name )
layout(matrix(c(1,2,3,4,5,6), 3, 2, byrow = TRUE),
widths=c(1.35,1), heights=c(1,1,1))
#interval-symbols-plot
ivs <-data['interval_symbols_time']
rownames(ivs)<-id
plot_time_figure(t(ivs),"\\tt{interval\\_symbols}",xmax=max(xmax,max(ivs)))
#constructor-plot
con <-data['constructs_time']
rownames(con)<-id
plot_time_figure(t(con),"\\tt{construct}",ylab=F,xlab=F,constructor=T)
#construction-size-plot
tsize<-data[[1,'TC_SIZE']]
consize <-(data['constructs_space']/tsize)*100
rownames(consize)<-id
plot_size_figure(t(consize),"\\tt{construction space}",ylab=T)
#size-plot
tsize<-data[[1,'TC_SIZE']]
size <-(data['wt_size']/tsize)*100
rownames(size)<-id
plot_size_figure(t(size),"\\tt{space}")
dev.off()
tex_doc <- paste(tex_doc,"\\begin{figure}[H]
\\input{",fig_name,"}
\\end{figure}")
#second page end
}
#type identification table
tex_doc<-paste(tex_doc,"\\begin{table}[b]
\\centering",
typeInfoTable("../wt.config",data[['WT_ID']], 1, 3, 2),
"\\caption{Wavelet tree identifier and corresponding sdsl-type.}
\\end{table}")
#read footer+end
tex_doc <- paste(tex_doc, readLines("wt-footer.tex"),collapse="\n")
sink(tex_file)
cat(tex_doc)
sink(NULL)
|