[tor-commits] [sbws/master] Add methods to log stats

juga at torproject.org juga at torproject.org
Tue Sep 18 09:26:11 UTC 2018


commit be90985edd6dff57d33be095cde1f3926382fd09
Author: juga0 <juga at riseup.net>
Date:   Fri Aug 31 14:07:53 2018 +0000

    Add methods to log stats
---
 sbws/lib/v3bwfile.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index 545cd77..5621557 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -724,6 +724,22 @@ class V3BWFile(object):
     def median_bw(self):
         return median([l.bw for l in self.bw_lines])
 
+    @property
+    def max_bw(self):
+        return max([l.bw for l in self.bw_lines])
+
+    @property
+    def min_bw(self):
+        return min([l.bw for l in self.bw_lines])
+
+    @property
+    def info_stats(self):
+        if not self.bw_lines:
+            return
+        [log.info(': '.join([attr, str(getattr(self, attr))])) for attr in
+         ['sum_bw', 'mean_bw', 'median_bw', 'num',
+          'max_bw', 'min_bw']]
+
     def bw_line_for_node_id(self, node_id):
         """Returns the bandwidth line for a given node fingerprint.
 





More information about the tor-commits mailing list