commit 16f6c8bf1c8acc4a9f190f34d1ae72acdf796b24 Author: Karsten Loesing karsten.loesing@gmx.net Date: Tue Oct 4 17:50:50 2011 +0200
Add a graph for task 4142. --- task-4142/.gitignore | 6 ++++++ task-4142/Eval.java | 38 ++++++++++++++++++++++++++++++++++++++ task-4142/README | 5 +++++ task-4142/delay.R | 16 ++++++++++++++++ 4 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/task-4142/.gitignore b/task-4142/.gitignore new file mode 100644 index 0000000..0ec473e --- /dev/null +++ b/task-4142/.gitignore @@ -0,0 +1,6 @@ +*.class +*.pdf +delay +*.csv +*.png + diff --git a/task-4142/Eval.java b/task-4142/Eval.java new file mode 100644 index 0000000..ee021d0 --- /dev/null +++ b/task-4142/Eval.java @@ -0,0 +1,38 @@ +import java.io.*; +import java.util.*; +public class Eval { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new FileReader("delay")); + String line, fingerprint = null, published = null; + Map<String, String> firstPublished = new HashMap<String, String>(); + while ((line = br.readLine()) != null) { + if (line.startsWith("extra-info ")) { + fingerprint = line.split(" ")[2]; + published = null; + } else if (line.startsWith("published ")) { + published = line.substring("published ".length()); + } else if (line.startsWith("dirreq-stats-end ")) { + String[] parts = line.split(" "); + String dirreqStatsEnd = parts[1] + " " + parts[2]; + String key = fingerprint + " " + dirreqStatsEnd; + if (!firstPublished.containsKey(key) || + firstPublished.get(key).compareTo(published) > 0) { + firstPublished.put(key, published); + } + } + } + br.close(); + BufferedWriter bw = new BufferedWriter(new FileWriter("delay.csv")); + bw.write("fingerprint,dirreqstatsend,published\n"); + for (Map.Entry<String, String> e : firstPublished.entrySet()) { + String[] parts = e.getKey().split(" "); + fingerprint = parts[0]; + String dirreqStatsEnd = parts[1] + " " + parts[2]; + published = e.getValue(); + bw.write(fingerprint + "," + dirreqStatsEnd + "," + published + + "\n"); + } + bw.close(); + } +} + diff --git a/task-4142/README b/task-4142/README new file mode 100644 index 0000000..5a25128 --- /dev/null +++ b/task-4142/README @@ -0,0 +1,5 @@ +$ grep -Rl "dirreq-stats-end" * | xargs -I{} grep -E \ + "published|dirreq-stats-end|^extra-info" {} > ../delay +$ javac Eval.java && java Eval +$ R --slave -f delay.R + diff --git a/task-4142/delay.R b/task-4142/delay.R new file mode 100644 index 0000000..5568e61 --- /dev/null +++ b/task-4142/delay.R @@ -0,0 +1,16 @@ +library(ggplot2) +d <- read.csv("delay.csv") +d <- data.frame(published = d$published, + dirreqstatsend = d$dirreqstatsend, + delay = as.POSIXlt(d$published) - as.POSIXlt(d$dirreqstatsend)) +m <- mean(as.numeric(d$delay)) / (60 * 60) +ggplot(d, aes(x = as.numeric(delay) / (60 * 60))) + +geom_histogram(binwidth = 1, fill = "purple2", + colour = alpha("white", 0.5)) + +scale_x_continuous(name = paste("\nDelay between finishing a", + "dirreq-stats interval and first publishing its results", + "(red line = mean value)"), minor_breaks = 1) + +scale_y_continuous(name = "Number of finished dirreq-stats intervals\n") + +geom_vline(xintercept = m, colour = "red", size = 1.5) + +ggsave("delay.png", width = 8, height = 5, dpi = 100) +
tor-commits@lists.torproject.org