X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba-papers.git/blobdiff_plain/5b5400d06cab932780185d192a82eb50f9ab6663..7f3a86f1595151f314547e4d7166f7d51df418f0:/supercomp11/data/script.r diff --git a/supercomp11/data/script.r b/supercomp11/data/script.r index 3440b86..ec331ea 100644 --- a/supercomp11/data/script.r +++ b/supercomp11/data/script.r @@ -1,5 +1,9 @@ ## Usage: launch R, and then: source("script.r") +## save, and chane default options +osp <- options("scipen") +options(scipen=3) + ## load dataset (variable is "ds") load("data.rda") @@ -39,11 +43,6 @@ draw <- function(dset = ds, ## 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)) @@ -63,7 +62,7 @@ draw <- function(dset = ds, ## draw the time axis on the left axis(2, labels=TRUE) - mtext("Simulated Time (s)", side=2, line=2.5) + mtext("Simulated time (s)", side=2, line=2.5) title(xlab="Algorithms") @@ -98,45 +97,64 @@ draw <- function(dset = ds, 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) +draw2 <- 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), ] + + ## keep only useful data + dset.long <- 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") + ## reshape data -> wide + dset.wide <- reshape(dset.long, direction="wide", + idvar="Algo", timevar="Size") - ## Rename rows - rownames(x.2) <- x.2$Algo - #colnames(x.2) <- sub("^[^.]*\\.", "", colnames(x.2)) + ## rename rows + rownames(dset.wide) <- sub("bookkeeping", "virtual", dset.wide$Algo) + #colnames(dset.wide) <- sub("^[^.]*\\.", "", colnames(dset.wide)) - ## Remove first column ("Algo") - x.3 <- as.matrix(x.2[-1]) + ## remove first column (aka "Algo") + dset.mat <- as.matrix(dset.wide[-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)) + dset.plot <- dset.mat[, c(FALSE,FALSE,TRUE)] + barplot(dset.plot, beside=TRUE, + names.arg=sub("^[^.]*\\.", "", colnames(dset.plot)), + col=rainbow(nrow(dset.mat), s=.5)) - x.4 <- x.3[, c(FALSE,TRUE,FALSE)] - barplot(x.4, beside=TRUE, + dset.plot <- dset.mat[, c(FALSE,TRUE,FALSE)] + barplot(dset.plot, beside=TRUE, axes=FALSE, axisnames=FALSE, add=TRUE, legend.text=TRUE, - col=rainbow(nrow(x.3))) + args.legend=list(x="topleft", inset=c(.02,0), title="Algorithms"), + col=rainbow(nrow(dset.mat))) - x.4 <- x.3[, c(TRUE,FALSE,FALSE)] - barplot(x.4, beside=TRUE, + dset.plot <- dset.mat[, c(TRUE,FALSE,FALSE)] + barplot(dset.plot, beside=TRUE, axes=FALSE, axisnames=FALSE, add=TRUE, - col=rainbow(nrow(x.3), v=.5)) + col=rainbow(nrow(dset.mat), 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)", + title(xlab="Platform size", + ylab="Simulated time (s)", main=t) } @@ -148,22 +166,43 @@ msg <- function(text, message(text) } +if (FALSE) { msg("First test, with algorithms \"plain\"...", wait = FALSE); -xx <- draw(subset(ds, grepl("[lt]_plain", Algo)), - draw_distrib="N") +draw(subset(ds, grepl("[lt]_plain", Algo)), draw_distrib="N") msg("... with draw2()...") -draw2(xx) +draw2(subset(ds, grepl("[lt]_plain", Algo)), draw_distrib="N") msg("Second test, with algorithms \"bookkeeping\"..."); -xx <- draw(subset(ds, grepl("[lt]_bookkeeping", Algo)), - draw_distrib="N") +draw(subset(ds, grepl("[lt]_bookkeeping", Algo)), draw_distrib="N") msg("... with draw2()...") -draw2(xx) +draw2(subset(ds, grepl("[lt]_bookkeeping", Algo)), draw_distrib="N") msg("Third test, with all algorithms..."); -xx <- draw(draw_distrib="N") +draw(draw_distrib="N") msg("... with draw2()...") -draw2(xx) +draw2(draw_distrib="N") +} + +system("mkdir -pv graphs") +for (m in c("R", "I")) { + for (d in c("1", "N")) { + for (r in c("10:1", "1:1", "1:10")) { + for (t in c("line", "torus", "hcube")) { + for (p in c("grid", "cluster")) { + message(sprintf(">>> Drawing: %s%s / %s / %s / %s", m, d, r, p, t)) + pdf(file=sprintf("graphs/%s%s-%s-%s-%s.pdf", m, d, r, p, t)) + draw2(#subset(ds, grepl("[lt]_plain", Algo)), + draw_mode=m, draw_distrib=d, draw_ratio=r, + draw_topo=t, draw_platform=p) + dev.off() + } + } + } + } +} + +## restore default options +options(scipen=osp)