[tor-commits] [onionperf/master] Adds support for recording seconds elapsed before downloading certain numbers of bytes

karsten at torproject.org karsten at torproject.org
Thu May 14 06:49:25 UTC 2020


commit d2086191602147b70c81e8a0f96c296bfa78b853
Author: Ana Custura <ana at netstat.org.uk>
Date:   Wed May 13 20:51:05 2020 +0100

    Adds support for recording seconds elapsed before downloading certain numbers of bytes
---
 README_JSON.md        | 11 +++++++++++
 onionperf/analysis.py |  6 ++++++
 2 files changed, 17 insertions(+)

diff --git a/README_JSON.md b/README_JSON.md
index e3e64dd..d057bb1 100644
--- a/README_JSON.md
+++ b/README_JSON.md
@@ -16,6 +16,17 @@ The structure is given here with variable keys marked as such.
                   "command": 0.319006, # step 7 if using a proxy, else step 3 (initial GET/PUT)
                   "first_byte": 0.0, # step 9 if using a proxy, else step 5 (initial GET/PUT)
                   "last_byte": 0.0, # step 11 if using a proxy, else step 7 (initial GET/PUT)
+                  "payload_bytes": { # similar to payload_progress below
+                    "10240": 0.0, # number of payload bytes completed : seconds to complete it
+                    "20480": 0.0,
+                    "51200": 0.0,
+                    "102400": 0.0,
+                    "204800": 0.0,
+                    "512000": 0.0,
+                    "1048576": 0.0,
+                    "2097152": 0.0,
+                    "5242880": 0.0
+                  },
                   "payload_progress": { # step 10 if using a proxy, else step 6 (initial GET/PUT)
                     "0.0": 0.0, # percent of payload completed : seconds to complete it
                     "0.1": 0.0,
diff --git a/onionperf/analysis.py b/onionperf/analysis.py
index 8e2b7df..3b5af27 100644
--- a/onionperf/analysis.py
+++ b/onionperf/analysis.py
@@ -414,9 +414,14 @@ class Transfer(object):
         self.id = tid
         self.last_event = None
         self.payload_progress = {decile:None for decile in [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]}
+        self.payload_bytes = {partial:None for partial in [10240, 20480, 51200, 102400, 204800, 512000, 1048576, 2097152, 5242880]}
 
     def add_event(self, status_event):
         progress_frac = float(status_event.payload_bytes_status) / float(status_event.filesize_bytes)
+        progress = float(status_event.payload_bytes_status)
+        for partial in sorted(self.payload_bytes.keys()):
+            if progress >= partial and self.payload_bytes[partial] is None:
+                self.payload_bytes[partial] = status_event.unix_ts_end
         for decile in sorted(self.payload_progress.keys()):
             if progress_frac >= decile and self.payload_progress[decile] is None:
                 self.payload_progress[decile] = status_event.unix_ts_end
@@ -429,6 +434,7 @@ class Transfer(object):
         d = e.__dict__
         if not e.is_error:
             d['elapsed_seconds']['payload_progress'] = {decile: self.payload_progress[decile] - e.unix_ts_start for decile in self.payload_progress if self.payload_progress[decile] is not None}
+            d['elapsed_seconds']['payload_bytes'] = {partial: self.payload_bytes[partial] - e.unix_ts_start for partial in self.payload_bytes if self.payload_bytes[partial] is not None}
         return d
 
 class Parser(object, metaclass=ABCMeta):





More information about the tor-commits mailing list