1 ## Usage: launch R, and then: source("script.r")
3 ## load dataset (variable is "ds")
6 ## extract data for plain algorithms, in real mode
7 #ds.base <- subset(ds, Mode == "R" & grepl("[lt]_plain", Algo))
9 ## extract data for one experiment
11 # Mode == "R" & Distrib == 1 & Ratio == "1:1" &
12 # Platform == "cluster" & Size == 16 & Topo == "line")
16 draw <- function(dset = ds,
20 draw_platform = "cluster",
21 draw_topo = "hcube") {
23 ## extract desired data
25 Mode == draw_mode & Distrib == draw_distrib &
27 Platform == draw_platform & Topo == draw_topo)
29 ## reorder lines (first "plain", then "bookkeeping")
30 dset <- rbind(subset(dset, grepl("plain", Algo)),
31 subset(dset, grepl("bookkeeping", Algo)))
32 dset <- dset[order(dset$Size), ]
34 ## finally, add an "Index" attribute(, for further processing
35 dset <- cbind(dset, Index=seq(1, length(dset$Size))) # FIXME
39 ## save the graphical parameters
40 p <- par(no.readonly=TRUE)
43 ### - add some spacing between each size
44 ### - fill in empty rows (e.g. with large size)
45 ### - add a label telling the size
47 par(mar=c(13, 4, 4, 4) + 0.1, # change margins
50 par(las=3) # always draw labels vertically
52 ## compute the time range: 0..max+20%
53 time_range <- c(0, range(dset$Conv_max)[2] * 1.2)
55 ## first draw the bars
56 barplot(dset$Conv_max, axes=FALSE, col="red",
59 barplot(dset$Conv_avg, axes=FALSE, col="green",
61 barplot(dset$Idle_avg, axes=FALSE, col="blue",
64 ## draw the time axis on the left
66 mtext("Time (s)", side=2, line=2.5)
68 title(xlab="Algorithms")
70 ## compute the data range
71 x_data_range <- c(0.6, length(dset$Algo) + 0.4)
72 data_range <- c(0, range(dset$Data_amnt)[2] * 1.04)
74 ## draw the data amnt line graphs
75 for (alg in unique(dset$Algo)) {
77 dset.da <- subset(dset, Algo == alg)
78 ## start a new graph, but drawn on the same device
80 plot(dset.da$Index, dset.da$Data_amnt, axes=FALSE, xlab="", type="b",
82 yaxs="i", ylim=data_range)
85 ## draw the data amnt axis on the right
87 mtext("Data amount (relative)", side=4, line=2.5)
90 t <- paste0(dset$Mode[1], dset$Distrib[1], " / ", dset$Ratio[1], " / ",
91 dset$Platform[1], " / ", dset$Topo[1])
94 ## restore the graphical parameters
102 readline("Press <Enter> to continue\n")
106 msg("First test, with algorithms \"plain\"...", wait = FALSE);
107 draw(subset(ds, grepl("[lt]_plain", Algo)))
109 msg("Second test, with algorithms \"bookkeeping\"...");
110 draw(subset(ds, grepl("[lt]_bookkeeping", Algo)))
112 msg("Third test, with all algorithms...");