Add graphing code for bandwidth by version (13634).
[tor-metrics-tasks.git] / task-1991 / torperf-guard-quantiles.R
blob2554c34d330fb8ff17e85515f084e95febdafc32
1 library(ggplot2)
3 # Read data
4 data <- read.csv("torperf-guard-bandwidths-ranks.csv",
5   stringsAsFactors = FALSE)
6 data <- data[(data$filesize == "50kb" & data$completiontime < 60000) |
7              (data$filesize == "1mb" & data$completiontime < 600000) |
8              (data$filesize == "5mb" & data$completiontime < 1500000), ]
9 data[data$filesize == "50kb", "filesize"] <- "a) 50 KB"
10 data[data$filesize == "1mb", "filesize"] <- "b) 1 MB"
11 data[data$filesize == "5mb", "filesize"] <- "c) 5 MB"
13 percentiles <- paste("p", seq(90, 90, 1), sep = "")
15 rq <- read.csv("torperf-guard-rank-quantiles.csv",
16   stringsAsFactors = FALSE)
17 rq[(rq$len < 30 & rq$filesize == "50kb") |
18    (rq$len < 10 & rq$filesize == "1mb") |
19    (rq$len < 5 & rq$filesize == "5mb"), percentiles] <- NA
20 rq <- rq[, c("filesize", "rank", percentiles)]
21 rq <- melt(rq, id = c("filesize", "rank"))
22 rq[rq$filesize == "50kb", "filesize"] <- "a) 50 KB"
23 rq[rq$filesize == "1mb", "filesize"] <- "b) 1 MB"
24 rq[rq$filesize == "5mb", "filesize"] <- "c) 5 MB"
25 ggplot(data, aes(x = as.numeric(rank), y = completiontime / 1000)) +
26 geom_point(alpha = 0.05) +
27 scale_x_continuous(paste("\nGuard rank by consensus bandwidth from",
28   "slowest (0) to fastest (1)"), limits = c(0, 1)) +
29 scale_y_continuous("Torperf completion time in seconds\n") +
30 geom_line(data = rq, aes(x = as.numeric(rank), y = value / 1000,
31   colour = variable)) +
32 facet_grid(filesize ~ ., scale = "free_y") +
33 opts(legend.position = "none")
34 ggsave(filename = "torperf-guard-rank-quantiles.png",
35   width = 8, height = 5, dpi = 150)
37 bq <- read.csv("torperf-guard-bandwidth-quantiles.csv",
38   stringsAsFactors = FALSE)
39 bq[(bq$len < 30 & bq$filesize == "50kb") |
40    (bq$len < 10 & bq$filesize == "1mb") |
41    (bq$len < 5 & bq$filesize == "5mb"), percentiles] <- NA
42 bq <- bq[, c("filesize", "bandwidth", percentiles)]
43 bq <- melt(bq, id = c("filesize", "bandwidth"))
44 bq[bq$filesize == "50kb", "filesize"] <- "a) 50 KB"
45 bq[bq$filesize == "1mb", "filesize"] <- "b) 1 MB"
46 bq[bq$filesize == "5mb", "filesize"] <- "c) 5 MB"
47 ggplot(data, aes(x = bandwidth / 1000, y = completiontime / 1000)) +
48 geom_point(alpha = 0.05) +
49 scale_x_continuous("\nGuard consensus bandwidth in MB/s") +
50 scale_y_continuous("Torperf completion time in seconds\n") +
51 geom_line(data = bq, aes(x = bandwidth / 1000, y = value / 1000,
52   colour = variable)) +
53 facet_grid(filesize ~ ., scale = "free_y") +
54 opts(legend.position = "none")
55 ggsave(filename = "torperf-guard-bandwidth-quantiles.png",
56   width = 8, height = 5, dpi = 150)