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

[tor-commits] [sbws/master] Use new methods to obtain bw line from results



commit f6cf9bfe808117c3d7d5fd468e6dcd0919e52dc8
Author: juga0 <juga@xxxxxxxxxx>
Date:   Wed Sep 5 12:25:15 2018 +0000

    Use new methods to obtain bw line from results
---
 sbws/lib/v3bwfile.py | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index f3e9bc9..b67b329 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -275,18 +275,27 @@ class V3BWLine(object):
         kwargs.update(cls.result_types_from_results(results))
         # useful args for scaling
         if success_results:
+            min_num_success_results = cls.min_num_results(success_results,
+                                                          min_num)
+            if not min_num_success_results:
+                return None
+            results_away = \
+                cls.results_away_each_other(min_num_success_results, secs_away)
+            results_recent = cls.results_recent_than(results_away, secs_recent)
+            if not results_recent:
+                return None
             # the most recent should be the last
             kwargs['desc_avg_bw_bs'] = \
-                success_results[-1].relay_average_bandwidth
-            kwargs['rtt'] = cls.rtt_from_results(success_results)
-            bw = cls.bw_bs_median_from_results(success_results)
-            kwargs['bw_bs_mean'] = cls.bw_bs_mean_from_results(success_results)
+                results_recent[-1].relay_average_bandwidth
+            kwargs['rtt'] = cls.rtt_from_results(results_recent)
+            bw = cls.bw_bs_median_from_results(results_recent)
+            kwargs['bw_bs_mean'] = cls.bw_bs_mean_from_results(results_recent)
             kwargs['bw_bs_median'] = cls.bw_bs_median_from_results(
-                success_results)
+                results_recent)
             kwargs['desc_obs_bw_bs_last'] = \
-                cls.desc_obs_bw_bs_last_from_results(success_results)
+                cls.desc_obs_bw_bs_last_from_results(results_recent)
             kwargs['desc_obs_bw_bs_mean'] = \
-                cls.desc_obs_bw_bs_mean_from_results(success_results)
+                cls.desc_obs_bw_bs_mean_from_results(results_recent)
             bwl = cls(node_id, bw, **kwargs)
             return bwl
         return None



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