diff --git a/DAS/__init__.py b/DAS/__init__.py index 84c1246..2368af7 100644 --- a/DAS/__init__.py +++ b/DAS/__init__.py @@ -2,3 +2,4 @@ from DAS.simulator import * from DAS.shape import * from DAS.visualizer import * from DAS.visualizor import * +from DAS.dequeViz import * diff --git a/DAS/dequeViz.py b/DAS/dequeViz.py new file mode 100644 index 0000000..c0d75bd --- /dev/null +++ b/DAS/dequeViz.py @@ -0,0 +1,33 @@ +#!/bin/python3 + +import matplotlib.pyplot as plt +import numpy as np +import os + +class DQ: + def __init__(self, sdq, rdq, tt): + self.sdq = sdq + self.rdq = rdq + self.tt = tt + +class DequeViz: + """This class helps the visualization of time taken for various deque size""" + + def __init__(self, execID, config): + """Initialize the visualizer module""" + self.execID = execID + self.config = config + os.makedirs("results/"+self.execID+"/dequePlot", exist_ok=True) + self.data = [] + + def addData(self, sdq, rdq, tt): + self.data.append(DQ(sdq, rdq, tt)) + self.data.sort(key=lambda x: (x.sdq, x.rdq)) + + def plotIt(self): + t = "" + for d in self.data: + t += f"{d.sdq}, {d.rdq}: {d.tt}\n" + with open("results/"+self.execID+"/dequePlot" + "/pt.txt", "w") as f: + f.write(t) + diff --git a/study.py b/study.py index 9eebea0..09791cf 100644 --- a/study.py +++ b/study.py @@ -5,6 +5,7 @@ import importlib import subprocess from joblib import Parallel, delayed from DAS import * +from DAS.dequeViz import * # Parallel execution: # The code currently uses 'joblib' to execute on multiple cores. For other options such as 'ray', see @@ -36,8 +37,9 @@ def runOnce(config, shape, execID): tic = time.time() result = sim.run() toc = time.time() - timed = f"(send: {shape.sendDqSize}, received: {shape.receivedDqSize}): {toc - tic}" - print(timed) + # timed = f"(send: {shape.sendDqSize}, received: {shape.receivedDqSize}): {toc - tic}" + # print(timed) + dqInfo = (shape.sendDqSize, shape.receivedDqSize, toc - tic) sim.logger.info("Shape: %s ... Block Available: %d in %d steps" % (str(sim.shape.__dict__), result.blockAvailable, len(result.missingVector)), extra=sim.format) if config.dumpXML: @@ -47,7 +49,7 @@ def runOnce(config, shape, execID): visual = Visualizor(execID, config, [result]) visual.plotAll() - return result + return result, dqInfo def study(): if len(sys.argv) < 2: @@ -89,6 +91,16 @@ def study(): start = time.time() results = Parallel(config.numJobs)(delayed(runOnce)(config, shape ,execID) for shape in config.nextShape()) end = time.time() + dqInfos = [] + heats = [] + for r in results: + heats.append(r[0]) + dqInfos.append(r[1]) + results = heats + dqViz = DequeViz(execID, config) + for info in dqInfos: + dqViz.addData(info[0], info[1], info[2]) + dqViz.plotIt() logger.info("A total of %d simulations ran in %d seconds" % (len(results), end-start), extra=format) if config.visualization: @@ -98,5 +110,6 @@ def study(): visual = Visualizor(execID, config, results) visual.plotHeatmaps("nn", "fr") +dqVizInfo = [] if __name__ == "__main__": study()