From 6c6e10b81f9b74b728cbe3b7a7ab4690bea7c889 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Thu, 26 Jan 2023 00:34:21 +0100 Subject: [PATCH] add tx/rx troughput statistics Collect statistics about Tx/Rx troughput, per timeslot and per node. Signed-off-by: Csaba Kiraly --- DAS/simulator.py | 2 ++ DAS/validator.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/DAS/simulator.py b/DAS/simulator.py index f1ccf76..8aaa80e 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -111,6 +111,8 @@ class Simulator: self.validators[i].sendColumns() self.validators[i].logRows() self.validators[i].logColumns() + for i in range(0,self.numberValidators): + self.validators[i].updateStats() arrived, expected = self.glob.checkStatus(self.validators) missingSamples = expected - arrived diff --git a/DAS/validator.py b/DAS/validator.py index c3923e0..3000cca 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -57,6 +57,12 @@ class Validator: self.rowNeighbors = collections.defaultdict(dict) self.columnNeighbors = collections.defaultdict(dict) + #statistics + self.statsTxInSlot = 0 + self.statsTxPerSlot = [] + self.statsRxInSlot = 0 + self.statsRxPerSlot = [] + def logIDs(self): if self.amIproposer == 1: self.logger.warning("I am a block proposer."% self.ID) @@ -103,6 +109,7 @@ class Validator: # register receive so that we are not sending back self.columnNeighbors[id][src].received |= column self.receivedBlock.mergeColumn(id, column) + self.statsRxInSlot += column.count(1) else: pass @@ -111,6 +118,7 @@ class Validator: # register receive so that we are not sending back self.rowNeighbors[id][src].received |= row self.receivedBlock.mergeRow(id, row) + self.statsRxInSlot += row.count(1) else: pass @@ -134,6 +142,14 @@ class Validator: self.block.merge(self.receivedBlock) + def updateStats(self): + self.logger.debug("Stats: tx %d, rx %d", self.statsTxInSlot, self.statsRxInSlot, extra=self.format) + self.statsRxPerSlot.append(self.statsRxInSlot) + self.statsTxPerSlot.append(self.statsTxInSlot) + self.statsRxInSlot = 0 + self.statsTxInSlot = 0 + + def sendColumn(self, columnID): line = self.getColumn(columnID) if line.any(): @@ -145,6 +161,7 @@ class Validator: if (toSend).any(): n.sent |= toSend; n.node.receiveColumn(columnID, toSend, self.ID) + self.statsTxInSlot += toSend.count(1) def sendRow(self, rowID): line = self.getRow(rowID) @@ -157,6 +174,7 @@ class Validator: if (toSend).any(): n.sent |= toSend; n.node.receiveRow(rowID, toSend, self.ID) + self.statsTxInSlot += toSend.count(1) def sendRows(self): if self.amIproposer == 1: