[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/maint-1.1] chg: scaling: Add filtered bandwidth function
commit 5159662a50b6ae97588e87423d6c56a9014ff91f
Author: juga0 <juga@xxxxxxxxxx>
Date: Sat May 16 17:07:19 2020 +0000
chg: scaling: Add filtered bandwidth function
to calculate the filtered bandwidth for each relay.
---
sbws/lib/scaling.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/sbws/lib/scaling.py b/sbws/lib/scaling.py
new file mode 100644
index 0000000..0fc3f84
--- /dev/null
+++ b/sbws/lib/scaling.py
@@ -0,0 +1,19 @@
+from statistics import mean
+
+
+def bw_measurements_from_results(results):
+ return [
+ dl['amount'] / dl['duration']
+ for r in results for dl in r.downloads
+ ]
+
+
+def bw_filt(bw_measurements):
+ """Filtered bandwidth for a relay.
+
+ It is the equivalent to Torflow's ``filt_sbw``.
+ ``mu`` in this function is the equivalent to Torflow's ``sbw``.
+ """
+ mu = mean(bw_measurements)
+ bws_gte_mean = filter(lambda bw: bw >= mu, bw_measurements)
+ return mean(bws_gte_mean)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits