summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Hawkins <[email protected]>2022-11-16 10:20:06 -0500
committerWill Hawkins <[email protected]>2022-11-16 10:22:20 -0500
commit10a52af363b0d52d78af0158cbaa404a1ce35b82 (patch)
tree5625c03873c597e4dfdf3a267e6bc0eb53def666
parent86f822c37f8fcc70d3a1085f4769ec58752f50c1 (diff)
[Feature] Add a Null Data Logger
The Null Data Logger will do nothing. This makes it possible to write unconditional code around logging -- there will *always* be a logger but sometimes that logger does, well, nothing.
-rw-r--r--datalogger/logger.go10
-rwxr-xr-xdatalogger/munge.py94
2 files changed, 104 insertions, 0 deletions
diff --git a/datalogger/logger.go b/datalogger/logger.go
index a6789d2..4c3b080 100644
--- a/datalogger/logger.go
+++ b/datalogger/logger.go
@@ -38,6 +38,16 @@ type CSVDataLogger[T any] struct {
destination io.WriteCloser
}
+type NullDataLogger[T any] struct{}
+
+func CreateNullDataLogger[T any]() DataLogger[T] {
+ return &NullDataLogger[T]{}
+}
+
+func (_ *NullDataLogger[T]) LogRecord(_ T) {}
+func (_ *NullDataLogger[T]) Export() bool { return true }
+func (_ *NullDataLogger[T]) Close() bool { return true }
+
func CreateCSVDataLogger[T any](filename string) (DataLogger[T], error) {
data := make([]T, 0)
destination, err := os.Create(filename)
diff --git a/datalogger/munge.py b/datalogger/munge.py
new file mode 100755
index 0000000..41b3dea
--- /dev/null
+++ b/datalogger/munge.py
@@ -0,0 +1,94 @@
+#!/bin/env python3
+
+from dataclasses import dataclass
+import csv
+
+@dataclass
+class ProbeDataPoint:
+ time: str
+ rtt_count: int
+ duration: float
+
+@dataclass
+class ThroughputDataPoint:
+ time: str
+ throughput: str
+
+def convertDuration(duration: str) -> str:
+ if duration.endswith("ms"):
+ return duration[0:-2]
+ elif duration.endswith("s"):
+ return str(float(duration[0:-1]) * 1000)
+
+if __name__ == '__main__':
+ # Let's open all the files!
+ foreign_dps = {}
+ self_dps = {}
+ dl_throughput_dps = {}
+ ul_throughput_dps = {}
+ max_happens_after = 0
+ with open("log-foreign-07-29-2022-14-36-39.csv") as foreign_dp_fh:
+ seen_header = False
+ for record in csv.reader(foreign_dp_fh):
+ if not seen_header:
+ seen_header = True
+ continue
+ foreign_dps[record[0]] = ProbeDataPoint(record[1], record[2], convertDuration(record[3]))
+ if int(record[0]) > max_happens_after:
+ max_happens_after = int(record[0])
+ with open("log-self-07-29-2022-14-36-39.csv") as self_dp_fh:
+ seen_header = False
+ for record in csv.reader(self_dp_fh):
+ if not seen_header:
+ seen_header = True
+ continue
+ self_dps[record[0]] = ProbeDataPoint(record[1], record[2], convertDuration(record[3]))
+ if int(record[0]) > max_happens_after:
+ max_happens_after = int(record[0])
+ with open("log-throughput-download07-29-2022-14-36-39.csv") as download_dp_fh:
+ seen_header = False
+ for record in csv.reader(download_dp_fh):
+ if not seen_header:
+ seen_header = True
+ continue
+ dl_throughput_dps[record[0]] = ThroughputDataPoint(record[1], record[2])
+ if int(record[0]) > max_happens_after:
+ max_happens_after = int(record[0])
+ with open("log-throughput-upload07-29-2022-14-36-39.csv") as upload_dp_fh:
+ seen_header = False
+ for record in csv.reader(upload_dp_fh):
+ if not seen_header:
+ seen_header = True
+ continue
+ ul_throughput_dps[record[0]] = ThroughputDataPoint(record[1], record[2])
+ if int(record[0]) > max_happens_after:
+ max_happens_after = int(record[0])
+
+ # Happens After, RT Count (self), RTT (self), RT Count (foreign), RTT (foreign), DL Throughput, UL Throughput
+ current = ["" for _ in range(0, 8)]
+ for ha in range(0, max_happens_after):
+ ha = str(ha)
+ found = True
+ if ha in self_dps:
+ print(f"{ha} is in self_dps")
+ current[0] = str(ha)
+ current[1] = self_dps[str(ha)].rtt_count
+ current[2] = self_dps[str(ha)].duration
+ elif ha in foreign_dps:
+ print(f"{ha} is in foreign_dps")
+ current[0] = str(ha)
+ current[3] = foreign_dps[str(ha)].rtt_count
+ current[4] = foreign_dps[str(ha)].duration
+ elif ha in dl_throughput_dps:
+ print(f"{ha} is in throughput download")
+ current[0] = str(ha)
+ current[5] = dl_throughput_dps[str(ha)].throughput
+ elif ha in ul_throughput_dps:
+ print(f"{ha} is in throughput upload")
+ current[0] = str(ha)
+ current[6] = ul_throughput_dps[str(ha)].throughput
+ else:
+ print(f"Cannot find {ha}.")
+ found = False
+ if found:
+ print(",".join(current)) \ No newline at end of file