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

[tor-commits] [torflow/master] Prevent file size list from double-listing percentiles.



commit a47e441e0a0e565e2101c1eb738aab6a800c132e
Author: Mike Perry <mikeperry-git@xxxxxxxxxx>
Date:   Mon Nov 14 17:10:45 2011 -0800

    Prevent file size list from double-listing percentiles.
    
    If two different file sizes serve one percentile, go with the smaller file
    size.
---
 NetworkScanners/BwAuthority/aggregate.py |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/NetworkScanners/BwAuthority/aggregate.py b/NetworkScanners/BwAuthority/aggregate.py
index ca202bb..fb5cc7a 100755
--- a/NetworkScanners/BwAuthority/aggregate.py
+++ b/NetworkScanners/BwAuthority/aggregate.py
@@ -280,17 +280,24 @@ def write_file_list(datadir):
   file_sizes.sort(reverse=True)
   node_fbws.sort()
   prev_size = file_sizes[-1]
+  prev_pct = 0
   i = 0
 
   # The idea here is to grab the largest file size such
   # that 5*bw < file, and do this for each file size.
   for bw in node_fbws:
     i += 1
+    pct = 100-(100*i)/len(node_fbws)
+    # If two different file sizes serve one percentile, go with the
+    # smaller file size (ie skip this one)
+    if pct == prev_pct:
+      continue
     for f in xrange(len(file_sizes)):
       if bw > file_sizes[f]*1024 and file_sizes[f] > prev_size:
         next_f = max(f-1,0)
-        file_pairs.append((100-(100*i)/len(node_fbws),files[file_sizes[next_f]]))
+        file_pairs.append((pct,files[file_sizes[next_f]]))
         prev_size = file_sizes[f]
+        prev_pct = pct
         break
 
   file_pairs.reverse()



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