From eb4f451303e3fc14bbf6aa3f0c6de4ea5039d63f Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 27 Mar 2023 23:11:40 +0200 Subject: [PATCH] save progress and traffic statistics to XML Signed-off-by: Csaba Kiraly --- DAS/simulator.py | 31 ++++++++++++++++++++++++++++++- config_example.py | 3 +++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/DAS/simulator.py b/DAS/simulator.py index 4bd0242..677a260 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -2,6 +2,7 @@ import networkx as nx import logging, random +import pandas as pd from functools import partial, partialmethod from datetime import datetime from DAS.tools import * @@ -168,6 +169,7 @@ class Simulator: arrived, expected, ready, validated = self.glob.checkStatus(self.validators) missingSamples = expected - arrived missingVector = [] + progressVector = [] trafficStatsVector = [] steps = 0 while(True): @@ -199,6 +201,31 @@ class Simulator: missingSamples, sampleProgress, nodeProgress, validatorProgress = self.glob.getProgress(self.validators) self.logger.debug("step %d, arrived %0.02f %%, ready %0.02f %%, validated %0.02f %%" % (steps, sampleProgress*100, nodeProgress*100, validatorProgress*100), extra=self.format) + + cnS = "samples received" + cnN = "nodes ready" + cnV = "validators ready" + cnT0 = "TX builder mean" + cnT1 = "TX class1 mean" + cnT2 = "TX class2 mean" + cnR1 = "RX class1 mean" + cnR2 = "RX class2 mean" + cnD1 = "Dup class1 mean" + cnD2 = "Dup class2 mean" + + progressVector.append({ + cnS:sampleProgress, + cnN:nodeProgress, + cnV:validatorProgress, + cnT0: trafficStats[0]["Tx"]["mean"], + cnT1: trafficStats[1]["Tx"]["mean"], + cnT2: trafficStats[2]["Tx"]["mean"], + cnR1: trafficStats[1]["Rx"]["mean"], + cnR2: trafficStats[2]["Rx"]["mean"], + cnD1: trafficStats[1]["RxDup"]["mean"], + cnD2: trafficStats[2]["RxDup"]["mean"], + }) + if missingSamples == oldMissingSamples: self.logger.debug("The block cannot be recovered, failure rate %d!" % self.shape.failureRate, extra=self.format) missingVector.append(missingSamples) @@ -210,7 +237,9 @@ class Simulator: else: steps += 1 + progress = pd.DataFrame(progressVector) + if self.config.saveProgress: + self.result.addMetric("progress", progress.to_dict(orient='list')) self.result.populate(self.shape, missingVector) - self.result.addMetric("trafficStats", trafficStatsVector) return self.result diff --git a/config_example.py b/config_example.py index af55fc2..5b1a396 100644 --- a/config_example.py +++ b/config_example.py @@ -19,6 +19,9 @@ import numpy as np from DAS.shape import Shape dumpXML = 1 + +# save progress vectors to XML +saveProgress = 1 visualization = 1 logLevel = logging.INFO