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

[tor-commits] [metrics-tasks/master] Add compute-hsdir-set-instability



commit 1532d9ed415ba4f5db6d888589dc48d22de6e42d
Author: Robert Ransom <rransom.8774@xxxxxxxxx>
Date:   Tue May 24 17:18:59 2011 -0700

    Add compute-hsdir-set-instability
---
 task-2649/compute-hsdir-set-instability     |   12 ++++
 task-2649/compute-hsdir-set-instability.tcl |   83 +++++++++++++++++++++++++++
 2 files changed, 95 insertions(+), 0 deletions(-)

diff --git a/task-2649/compute-hsdir-set-instability b/task-2649/compute-hsdir-set-instability
new file mode 100755
index 0000000..1a5e767
--- /dev/null
+++ b/task-2649/compute-hsdir-set-instability
@@ -0,0 +1,12 @@
+#!/bin/sh -e
+
+# This script must be run as ./compute-hsdir-set-instability .
+
+
+find out/consensus-hsdir-lists -type f -print |
+sort |
+tclsh8.5 compute-hsdir-set-instability.tcl |
+tee out/hsdir-set-instability |
+sed -e 's/$/                    /' |
+tr '\n' '\r'
+
diff --git a/task-2649/compute-hsdir-set-instability.tcl b/task-2649/compute-hsdir-set-instability.tcl
new file mode 100644
index 0000000..24afb97
--- /dev/null
+++ b/task-2649/compute-hsdir-set-instability.tcl
@@ -0,0 +1,83 @@
+
+set hsdir_set_name_list {}
+
+array set hsdir_sets {}
+
+proc read_file_lines {filename} {
+    set chanid [open $filename r]
+    set contents [read -nonewline $chanid]
+    close $chanid
+
+    return [split $contents "\n"]
+}
+
+proc get_hsdir_set_name {filename} {
+    return [file tail $filename]
+}
+
+proc read_hsdir_set {set_name filename} {
+    global hsdir_sets
+
+    set hsdir_set [read_file_lines $filename]
+    set hsdir_sets($set_name) $hsdir_set
+}
+
+proc forget_hsdir_set {name} {
+    unset -nocomplain hsdir_sets($name)
+}
+
+proc list_set_symmetric_difference_size {l1 l2} {
+    set l1 [lsort -ascii -unique $l1]
+    set l2 [lsort -ascii -unique $l2]
+    set both [lsort -ascii -unique [concat $l1 $l2]]
+
+    set l1i 0
+    set l2i 0
+    #set result {}
+    set result_length 0
+
+    foreach x $both {
+        set n_inputs_containing_x 0
+        if {[lindex $l1 $l1i] eq $x} {
+            incr l1i
+            incr n_inputs_containing_x
+        }
+        if {[lindex $l2 $l2i] eq $x} {
+            incr l2i
+            incr n_inputs_containing_x
+        }
+        if {$n_inputs_containing_x & 1} {
+            #lappend result $x
+            incr result_length
+        }
+    }
+
+    #return $result
+    return $result_length
+}
+rename list_set_symmetric_difference_size lssds
+
+while {![eof stdin]} {
+    set x [gets stdin hsdir_set_filename]
+    if {$x == -1} {break}
+
+    set hsdir_set_name [get_hsdir_set_name $hsdir_set_filename]
+    read_hsdir_set $hsdir_set_name $hsdir_set_filename
+
+    lappend hsdir_set_name_list $hsdir_set_name
+
+    if {[llength $hsdir_set_name_list] == 5} {
+        lassign $hsdir_set_name_list set0 set1 set2 set3 set4
+
+        puts "$set0\
+              [llength $hsdir_sets($set0)]\
+              [lssds $hsdir_sets($set0) $hsdir_sets($set1)]\
+              [lssds $hsdir_sets($set0) $hsdir_sets($set2)]\
+              [lssds $hsdir_sets($set0) $hsdir_sets($set3)]\
+              [lssds $hsdir_sets($set0) $hsdir_sets($set4)]"
+
+        forget_hsdir_set [lindex $hsdir_set_name_list 0]
+        set hsdir_set_name_list [lrange $hsdir_set_name_list 1 end]
+    }
+}
+



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