[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [metrics-tasks/master] Add yet another graph (#15513).



commit 7822084eef8ba5ddc657b7fed420f208daef86ba
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Wed Apr 22 16:27:05 2015 +0200

    Add yet another graph (#15513).
---
 task-15513/plot.R                    |   11 ++++++++
 task-15513/src/ParseDescriptors.java |   48 ++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff --git a/task-15513/plot.R b/task-15513/plot.R
index 26fc854..4f83c6d 100644
--- a/task-15513/plot.R
+++ b/task-15513/plot.R
@@ -92,3 +92,14 @@ ggplot(l, aes(x = as.POSIXct(publication,
   scale_y_continuous("") +
   ggtitle("Number of introduction points over time\n")
 
+l <- read.csv("novel-introduction-points.csv")
+ggplot(l, aes(
+  x = as.POSIXct(publication / 1000, origin = "1970-01-01 00:00:00"),
+  y = distinctrelays, colour = service)) +
+  geom_line() +
+  scale_x_datetime("") +
+  scale_y_continuous("Cumulative number of relays\n") +
+  scale_colour_hue("Service") +
+  ggtitle(paste("Cumulative number of distinct relays\nused for",
+                "establishing introduction points\n"))
+
diff --git a/task-15513/src/ParseDescriptors.java b/task-15513/src/ParseDescriptors.java
index ef4d77f..5ed2887 100644
--- a/task-15513/src/ParseDescriptors.java
+++ b/task-15513/src/ParseDescriptors.java
@@ -60,6 +60,10 @@ public class ParseDescriptors {
 
     writeIntroductionPointsPerRelay(parsedDescriptors,
         new File("intros-per-relay.csv"), "service,intros");
+
+    writeNovelIntroductionPoints(parsedDescriptors,
+        new File("novel-introduction-points.csv"),
+        "service,publication,distinctrelays");
   }
 
   private static SortedMap<String, SortedMap<Long, List<Set<String>>>>
@@ -417,4 +421,48 @@ public class ParseDescriptors {
     }
     bw.close();
   }
+
+  private static void writeNovelIntroductionPoints(SortedMap<String,
+      SortedMap<Long, List<Set<String>>>> parsedDescriptors,
+      File csvFile, String header) throws IOException {
+    SortedMap<String, /* <- service name */
+        SortedMap<Long, /* <- publication time */
+        Integer>> /* <- distinct relays used for introduction points */
+        novelIntroductionPoints =
+        new TreeMap<String, SortedMap<Long, Integer>>();
+    for (Map.Entry<String, SortedMap<Long, List<Set<String>>>> e0 :
+        parsedDescriptors.entrySet()) {
+      String serviceName = e0.getKey();
+      SortedMap<Long, Integer> novelIntroductionPointsThisService =
+          new TreeMap<Long, Integer>();
+      Set<String> relaysSeenSoFar = new HashSet<String>();
+      for (Map.Entry<Long, List<Set<String>>> e1 :
+          e0.getValue().entrySet()) {
+        long publicationTime = e1.getKey();
+        for (Set<String> introductionPoints : e1.getValue()) {
+          for (String introductionPoint : introductionPoints) {
+            String[] parts = introductionPoint.split("-");
+            String fingerprint = parts[0];
+            if (!relaysSeenSoFar.contains(fingerprint)) {
+              relaysSeenSoFar.add(fingerprint);
+              novelIntroductionPointsThisService.put(
+                  publicationTime, relaysSeenSoFar.size());
+            }
+          }
+        }
+      }
+      novelIntroductionPoints.put(serviceName,
+          novelIntroductionPointsThisService);
+    }
+    BufferedWriter bw = new BufferedWriter(new FileWriter(csvFile));
+    bw.write(header + "\n");
+    for (Map.Entry<String, SortedMap<Long, Integer>> e0 :
+        novelIntroductionPoints.entrySet()) {
+      for (Map.Entry<Long, Integer> e1 : e0.getValue().entrySet()) {
+        bw.write(e0.getKey() + "," + e1.getKey() + "," + e1.getValue()
+            + "\n");
+      }
+    }
+    bw.close();
+  }
 }

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits