[tor-commits] [metrics-tasks/master] Add graphing code for #4776.

karsten at torproject.org karsten at torproject.org
Tue Jan 24 10:44:29 UTC 2012


commit 0434eaa4c611dae64ac059d494ed3decfeb99374
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Jan 24 11:43:42 2012 +0100

    Add graphing code for #4776.
---
 task-4776/.gitignore  |    3 ++
 task-4776/advbw-cdf.R |   63 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/task-4776/.gitignore b/task-4776/.gitignore
new file mode 100644
index 0000000..cccc5e9
--- /dev/null
+++ b/task-4776/.gitignore
@@ -0,0 +1,3 @@
+*.png
+*.tar
+
diff --git a/task-4776/advbw-cdf.R b/task-4776/advbw-cdf.R
new file mode 100644
index 0000000..c596927
--- /dev/null
+++ b/task-4776/advbw-cdf.R
@@ -0,0 +1,63 @@
+library("RPostgreSQL")
+library("DBI")
+library("ggplot2")
+library("proto")
+library("grid")
+library("reshape")
+library("plyr")
+library("digest")
+
+db = "tordir"
+dbuser = "metrics"
+dbpassword= "password"
+
+plot_advbw_cdf <- function(datetime, path, xlimit, dpi) {
+  drv <- dbDriver("PostgreSQL")
+  con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
+  q <- paste("SELECT LEAST(descriptor.bandwidthavg, ",
+             "descriptor.bandwidthburst, ",
+             "descriptor.bandwidthobserved) AS advbw ",
+             "FROM statusentry ",
+             "RIGHT JOIN descriptor ",
+             "ON statusentry.descriptor = descriptor.descriptor ",
+             "WHERE statusentry.validafter = '", datetime, "' ",
+             "ORDER BY 1", sep = "")
+  rs <- dbSendQuery(con, q)
+  u <- fetch(rs, n = -1)
+  dbDisconnect(con)
+  dbUnloadDriver(drv)
+  ggplot(u, aes(x = sort(advbw / 1024),
+    y = (1:length(advbw)) / length(advbw))) +
+  geom_line(size = 1) +
+  scale_x_continuous(name = "\nAdvertised bandwidth in KiB/s",
+    limit = c(0, xlimit)) +
+  scale_y_continuous(formatter = "percent",
+    name = "Fraction of relays with that bandwidth or less\n") +
+  opts(title = paste(datetime, "\n", sep = ""))
+  ggsave(filename = path, width = 8, height = 5, dpi = as.numeric(dpi))
+}
+plot_advbw_cdf('2011-02-03 12:00:00', 'advbw-cdf-2011-02-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-03-03 12:00:00', 'advbw-cdf-2011-03-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-04-03 12:00:00', 'advbw-cdf-2011-04-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-05-03 12:00:00', 'advbw-cdf-2011-05-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-06-03 12:00:00', 'advbw-cdf-2011-06-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-07-03 12:00:00', 'advbw-cdf-2011-07-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-08-03 12:00:00', 'advbw-cdf-2011-08-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-09-03 12:00:00', 'advbw-cdf-2011-09-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-10-03 12:00:00', 'advbw-cdf-2011-10-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-11-03 12:00:00', 'advbw-cdf-2011-11-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2011-12-03 12:00:00', 'advbw-cdf-2011-12-03-12-00-00.png',
+  1024, 72)
+plot_advbw_cdf('2012-01-03 12:00:00', 'advbw-cdf-2012-01-03-12-00-00.png',
+  1024, 72)
+



More information about the tor-commits mailing list