Add code for web logs analysis (#20008).
[tor-metrics-tasks.git] / task-15513 / plot.R
blob24bce6441502c8afe8d7ea02a438eed8d6560c38
1 require(ggplot2)
2 require(reshape)
3 require(scales)
5 l <- read.csv("lifetimes.csv")
6 ggplot(l, aes(x = lifetime_millis / 3600000, colour = service)) +
7   stat_ecdf() +
8   scale_x_continuous("\nLifetime in hours",
9     limits = c(0, max(l$lifetime_millis) / 3600000)) +
10   scale_y_continuous("Cumulative fraction\n", labels = percent) +
11   scale_colour_hue("Service", labels = c("a", "b", "c", "d", "e", "f")) +
12   ggtitle("Lifetime of introduction points\n")
13 ggsave("lifetimes-2015-07-14-a.png", width = 8, height = 5, dpi = 100)
15 l <- read.csv("published-descs.csv")
16 ggplot(l, aes(x = descs, colour = service)) +
17   stat_ecdf() +
18   scale_x_continuous("\nNumber of descriptors",
19     limits = c(0, max(l$descs))) +
20   scale_y_continuous("Cumulative fraction\n", labels = percent) +
21   scale_colour_hue("Service", labels = c("a", "b", "c", "d", "e", "f")) +
22   ggtitle(paste("Number of descriptors published per hour,\n",
23     "including descriptor replicas\n", sep = ""))
24 ggsave("lifetimes-2015-07-14-b.png", width = 8, height = 5, dpi = 100)
26 l <- read.csv("established-intros.csv")
27 ggplot(l, aes(x = intros, colour = service)) +
28   stat_ecdf() +
29   scale_x_continuous("\nNumber of introduction points",
30     limits = c(0, max(l$intros))) +
31   scale_y_continuous("Cumulative fraction\n", labels = percent) +
32   scale_colour_hue("Service", labels = c("a", "b", "c", "d", "e", "f")) +
33   ggtitle("Number of distinct introduction points used per hour\n")
34 ggsave("lifetimes-2015-07-14-c.png", width = 8, height = 5, dpi = 100)
36 l <- read.csv("intros-per-desc.csv")
37 ggplot(l, aes(x = introsperdesc, colour = service)) +
38   stat_ecdf() +
39   scale_x_continuous("\nNumber of introduction points per descriptor",
40     limits = c(0, max(l$introsperdesc)),
41     breaks = seq(0, max(l$introsperdesc), 2)) +
42   scale_y_continuous("Cumulative fraction\n", labels = percent) +
43   scale_colour_hue("Service", labels = c("a", "b", "c", "d", "e", "f")) +
44   ggtitle("Number of introduction points per descriptor\n")
45 ggsave("lifetimes-2015-07-14-d.png", width = 8, height = 5, dpi = 100)
47 l <- read.csv("intros-per-relay.csv")
48 data <- rbind(
49   data.frame(x = sort(l[l$service == "4cjw6cwpeaeppfqz" , 2]),
50              y = (1:length(l[l$service == "4cjw6cwpeaeppfqz" , 2])),
51              colour = "4cjw6cwpeaeppfqz"),
52   data.frame(x = sort(l[l$service == "agorahooawayyfoe" , 2]),
53              y = (1:length(l[l$service == "agorahooawayyfoe" , 2])),
54              colour = "agorahooawayyfoe"),
55   data.frame(x = sort(l[l$service == "facebookcorewwwi" , 2]),
56              y = (1:length(l[l$service == "facebookcorewwwi" , 2])),
57              colour = "facebookcorewwwi"),
58   data.frame(x = sort(l[l$service == "kpvz7kpmcmne52qf" , 2]),
59              y = (1:length(l[l$service == "kpvz7kpmcmne52qf" , 2])),
60              colour = "kpvz7kpmcmne52qf"),
61   data.frame(x = sort(l[l$service == "xdndo2okt43cjx44" , 2]),
62              y = (1:length(l[l$service == "xdndo2okt43cjx44" , 2])),
63              colour = "xdndo2okt43cjx44"))
65 ggplot(data) +
66   geom_step(aes(x = x, y = y, colour = as.factor(colour))) +
67   scale_x_continuous("\nIntroduction points established on same relay",
68     limits = c(0, max(data$x))) +
69   scale_y_continuous(paste("Cumulative number of relays used for",
70     "introduction points\n")) +
71   scale_colour_hue("Service", labels = c("a", "b", "c", "d", "e", "f")) +
72   ggtitle(paste("Number of introduction points established on\nthe",
73     "same relay (in the measurement period)\n"))
74 ggsave("lifetimes-2015-07-14-e.png", width = 8, height = 5, dpi = 100)
76 data <- data[as.character(data$colour) != "agorahooawayyfoe", ]
77 ggplot(data) +
78   geom_step(aes(x = x, y = y, colour = as.factor(colour))) +
79   scale_x_continuous("\nIntroduction points established on same relay",
80     limits = c(0, max(data$x, na.rm = TRUE))) +
81   scale_y_continuous(paste("Cumulative number of relays used for",
82     "introduction points\n")) +
83   scale_colour_hue("Service", labels = c("a", "b", "c", "d", "e", "f")) +
84   ggtitle(paste("Number of introduction points established on\nthe",
85     "same relay (in the measurement period)\n"))
86 ggsave("lifetimes-2015-07-14-f.png", width = 8, height = 5, dpi = 100)
88 l <- read.csv("intros-per-desc.csv")
89 l <- data.frame(l,
90   scrubbed = ifelse(l$service == "4cjw6cwpeaeppfqz", "a",
91              ifelse(l$service == "agorahooawayyfoe", "b",
92              ifelse(l$service == "facebookcorewwwi", "c",
93              ifelse(l$service == "kpvz7kpmcmne52qf", "d",
94              ifelse(l$service == "msydqstlz2kzerdg", "e",
95              "f"))))))
96 l <- aggregate(list(introsperdesc = l$introsperdesc), by = list(
97   publication = (l$publication %/% (1 * 3600 * 1000)) * (1 * 3600),
98   scrubbed = l$scrubbed), FUN = max)
99 ggplot(l, aes(x = as.POSIXct(publication,
100     origin = "1970-01-01 00:00:00"), y = introsperdesc, fill = scrubbed)) +
101   geom_area() +
102   scale_fill_hue("", guide = "none") +
103   facet_grid(scrubbed ~ .) +
104   scale_x_datetime("") +
105   scale_y_continuous("") +
106   ggtitle("Number of introduction points over time\n")
107 ggsave("lifetimes-2015-07-14-g.png", width = 8, height = 5, dpi = 100)
109 l <- read.csv("novel-introduction-points.csv")
110 ggplot(l, aes(
111   x = as.POSIXct(publication / 1000, origin = "1970-01-01 00:00:00"),
112   y = distinctrelays, colour = service)) +
113   geom_line() +
114   scale_x_datetime("") +
115   scale_y_continuous("Cumulative number of relays\n") +
116   scale_colour_hue("Service", labels = c("a", "b", "c", "d", "e", "f")) +
117   ggtitle(paste("Cumulative number of distinct relays\nused for",
118                 "establishing introduction points\n"))
119 ggsave("lifetimes-2015-07-14-h.png", width = 8, height = 5, dpi = 100)