diff --git a/DAS/observer.py b/DAS/observer.py index 0086120..173a0d9 100644 --- a/DAS/observer.py +++ b/DAS/observer.py @@ -86,6 +86,22 @@ class Observer: return missingSamples, sampleProgress, nodeProgress, validatorAllProgress, validatorProgress + def getSamplingProgress(self, validators): + arrived = 0 + expected = 0 + ready = 0 + nodes = 0 + + for val in validators: + if val.amIproposer == 0: + (a, e) = val.checkDAS() + arrived += a + expected += e + if a == e: + ready += 1 + nodes += 1 + return (arrived / expected, ready / nodes) + def getTrafficStats(self, validators): """Summary statistics of traffic measurements in a timestep.""" def maxOrNan(l): diff --git a/DAS/simulator.py b/DAS/simulator.py index c860f31..4a33ce1 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -257,6 +257,7 @@ class Simulator: self.validators[i].send() self.logger.debug("PHASE PROGRESS STATS %d" % steps, extra=self.format) missingSamples, sampleProgress, nodeProgress, validatorAllProgress, validatorProgress = self.glob.getProgress(self.validators) + samplingProgress, _ = self.glob.getSamplingProgress(self.validators) self.logger.debug("PHASE RECEIVE %d" % steps, extra=self.format) for i in range(1,self.shape.numberNodes): self.validators[i].receiveRowsColumns() @@ -279,12 +280,14 @@ class Simulator: self.validators[i].updateStats() trafficStatsVector.append(trafficStats) - self.logger.info("step %d, arrived %0.02f %%, ready %0.02f %%, validatedall %0.02f %%, , validated %0.02f %%" - % (steps, sampleProgress*100, nodeProgress*100, validatorAllProgress*100, validatorProgress*100), extra=self.format) + self.logger.info("step %d, arrived %0.02f %%, ready %0.02f %%, validatedall %0.02f %%, validated %0.02f %%, sampled %0.02f %%" + % (steps, sampleProgress*100, nodeProgress*100, validatorAllProgress*100, validatorProgress*100, + samplingProgress*100), extra=self.format) cnS = "samples received" cnN = "nodes ready" cnV = "validators ready" + cnDAS = "DASampling ready" cnT0 = "TX builder mean" cnT1 = "TX class1 mean" cnT2 = "TX class2 mean" @@ -297,6 +300,7 @@ class Simulator: cnS:sampleProgress, cnN:nodeProgress, cnV:validatorProgress, + cnDAS:samplingProgress, cnT0: trafficStats[0]["Tx"]["mean"], cnT1: trafficStats[1]["Tx"]["mean"], cnT2: trafficStats[2]["Tx"]["mean"], diff --git a/DAS/visualizor.py b/DAS/visualizor.py index 5eab2f7..58576d5 100644 --- a/DAS/visualizor.py +++ b/DAS/visualizor.py @@ -112,6 +112,7 @@ class Visualizor: vector1 = result.metrics["progress"]["nodes ready"] vector2 = result.metrics["progress"]["validators ready"] vector3 = result.metrics["progress"]["samples received"] + vector4 = result.metrics["progress"]["DASampling ready"] conf = {} attrbs = self.__get_attrbs__(result) conf["textBox"] = "Block Size R: "+attrbs['bsrn']+"\nBlock Size C: "+attrbs['bscn']\ @@ -120,11 +121,11 @@ class Visualizor: conf["type"] = "plot" conf["legLoc"] = 2 conf["desLoc"] = 2 - conf["colors"] = ["g-", "b-", "r-"] - conf["labels"] = ["Nodes", "Validators", "Samples"] + conf["colors"] = ["g-", "b-", "r-", "m-"] + conf["labels"] = ["Nodes", "Validators", "Samples", "DASampling"] conf["xlabel"] = "Time (ms)" conf["ylabel"] = "Percentage (%)" - conf["data"] = [vector1, vector2, vector3] + conf["data"] = [vector1, vector2, vector3, vector4] conf["xdots"] = [x*self.config.stepDuration for x in range(len(vector1))] conf["path"] = plotPath+"/nodesReady.png" maxi = 0