X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba-papers.git/blobdiff_plain/4b0c0716f84d562ede752dde852a825a2c3aa46c..47d970c595adbdf48d5340fe34cf3d81b012788a:/supercomp11/data/script.r diff --git a/supercomp11/data/script.r b/supercomp11/data/script.r index ffac783..3440b86 100644 --- a/supercomp11/data/script.r +++ b/supercomp11/data/script.r @@ -1,13 +1,169 @@ -# load dataset (variable is "ds") +## Usage: launch R, and then: source("script.r") + +## load dataset (variable is "ds") load("data.rda") -# extract data for plain algorithms, in real mode -ds.base <- subset(ds, Mode=="R" & grepl("[lt]_plain", Algo)) +## extract data for plain algorithms, in real mode +#ds.base <- subset(ds, Mode == "R" & grepl("[lt]_plain", Algo)) + +## extract data for one experiment +#xx <- subset(ds, +# Mode == "R" & Distrib == 1 & Ratio == "1:1" & +# Platform == "cluster" & Size == 16 & Topo == "line") + + + +draw <- function(dset = ds, + draw_mode = "R", + draw_distrib = 1, + draw_ratio = "1:1", + draw_platform = "cluster", + draw_topo = "hcube") { + + ## extract desired data + dset <- subset(dset, + Mode == draw_mode & Distrib == draw_distrib & + Ratio == draw_ratio & + Platform == draw_platform & Topo == draw_topo) + + ## reorder lines (first "plain", then "bookkeeping") + dset <- rbind(subset(dset, grepl("plain", Algo)), + subset(dset, grepl("bookkeeping", Algo))) + dset <- dset[order(dset$Size), ] + + ## finally, add an "Index" attribute(, for further processing + dset <- cbind(dset, Index=seq(1, length(dset$Size))) # FIXME + + #print(dset) + + ## save the graphical parameters + p <- par(no.readonly=TRUE) + +### TODO +### - add some spacing between each size +### - fill in empty rows (e.g. with large size) +### - add a label telling the size + + par(mar=c(13, 4, 4, 4) + 0.1, # change margins + mgp=c(11, 1, 0)) + + par(las=3) # always draw labels vertically + + ## compute the time range: 0..max+20% + time_range <- c(0, range(dset$Conv_max)[2] * 1.2) + + ## first draw the bars + barplot(dset$Conv_max, axes=FALSE, col="red", + names=dset$Algo, + ylim=time_range) + barplot(dset$Conv_avg, axes=FALSE, col="green", + add=TRUE) + barplot(dset$Idle_avg, axes=FALSE, col="blue", + add=TRUE) + + ## draw the time axis on the left + axis(2, labels=TRUE) + mtext("Simulated Time (s)", side=2, line=2.5) + + title(xlab="Algorithms") + + ## compute the data range + x_data_range <- c(0.6, length(dset$Algo) + 0.4) + data_range <- c(0, range(dset$Data_amnt)[2] * 1.04) + + ## draw the data amnt line graphs + for (alg in unique(dset$Algo)) { + print(alg); + dset.da <- subset(dset, Algo == alg) + ## start a new graph, but drawn on the same device + par(new=TRUE) + plot(dset.da$Index, dset.da$Data_amnt, axes=FALSE, xlab="", type="b", + xlim=x_data_range, + yaxs="i", ylim=data_range) + } + + ## draw the data amnt axis on the right + axis(4, labels=TRUE) + mtext("Data amount (relative)", side=4, line=2.5) -xx <- subset(ds.base, Ratio == "1:1" & Topo == "line" & Distrib == 1) -plot(xx$Size, xx$Conv_max, xlab="Size", ylab="Time") + ## finally, set title + t <- paste0(dset$Mode[1], dset$Distrib[1], " / ", + dset$Ratio[1], " / ", + dset$Platform[1], " / ", dset$Topo[1]) + title(main=t) -for(pl in c("cluster", "grid")) { - yy <- subset(xx, Platform == pl) - points(yy$Size, yy$Conv_max, xlab="Size", ylab="Time") + ## restore the graphical parameters + par(p) + + return(dset) } + +draw2 <- function(dset) { + ## Extract useful data + x.1 <- data.frame(Algo=dset$Algo, Size=dset$Size, + Idle_avg=dset$Idle_avg, + Conv_avg=dset$Conv_avg, + Conv_max=dset$Conv_max) + + ## Reshape data -> wide + x.2 <- reshape(x.1, direction="wide", idvar="Algo", timevar="Size") + + ## Rename rows + rownames(x.2) <- x.2$Algo + #colnames(x.2) <- sub("^[^.]*\\.", "", colnames(x.2)) + + ## Remove first column ("Algo") + x.3 <- as.matrix(x.2[-1]) + + x.4 <- x.3[, c(FALSE,FALSE,TRUE)] + barplot(x.4, beside=TRUE, + names.arg=sub("^[^.]*\\.", "", colnames(x.4)), + col=rainbow(nrow(x.3), s=.5)) + + x.4 <- x.3[, c(FALSE,TRUE,FALSE)] + barplot(x.4, beside=TRUE, + axes=FALSE, axisnames=FALSE, add=TRUE, + legend.text=TRUE, + col=rainbow(nrow(x.3))) + + x.4 <- x.3[, c(TRUE,FALSE,FALSE)] + barplot(x.4, beside=TRUE, + axes=FALSE, axisnames=FALSE, add=TRUE, + col=rainbow(nrow(x.3), v=.5)) + + ## finally, set titles + t <- paste0(dset$Mode[1], dset$Distrib[1], " / ", + dset$Ratio[1], " / ", + dset$Platform[1], " / ", dset$Topo[1]) + title(xlab="Platform Size", + ylab="Simulated Time (s)", + main=t) + +} + +msg <- function(text, + wait = TRUE) { + if (wait) + readline("Press to continue\n") + message(text) +} + +msg("First test, with algorithms \"plain\"...", wait = FALSE); +xx <- draw(subset(ds, grepl("[lt]_plain", Algo)), + draw_distrib="N") + +msg("... with draw2()...") +draw2(xx) + +msg("Second test, with algorithms \"bookkeeping\"..."); +xx <- draw(subset(ds, grepl("[lt]_bookkeeping", Algo)), + draw_distrib="N") + +msg("... with draw2()...") +draw2(xx) + +msg("Third test, with all algorithms..."); +xx <- draw(draw_distrib="N") + +msg("... with draw2()...") +draw2(xx)