diff --git a/DRAMSys/traceAnalyzer/scripts/plots.py b/DRAMSys/traceAnalyzer/scripts/plots.py index 990ba912..dc6def9f 100755 --- a/DRAMSys/traceAnalyzer/scripts/plots.py +++ b/DRAMSys/traceAnalyzer/scripts/plots.py @@ -196,6 +196,55 @@ def memory_utilisation_window(connection, tracePath, steps): return outputFiles +@plot +def queue_window(connection, tracePath, steps): + + import matplotlib.pyplot as plt + from matplotlib.backends.backend_pdf import PdfPages + + cursor = connection.cursor() + cursor.execute("select max(BufferNumber) from BufferDepth;") + bufferNumber = int(cursor.fetchone()[0]) + 1 + + cursor = connection.cursor() + cursor.execute("select MaxBufferDepth from GeneralInfo;") + maxBufferDepth = int(cursor.fetchone()[0]) + + outputFile = "" + outputFileName, basename = createOutputFilename(tracePath, 'queue', '', 'pdf') + outputFile = "{0}\n\t".format(outputFileName) + + QueueFigure = plt.figure(figsize=(10, 5), dpi=300) + QueueFigurePlot = QueueFigure.add_subplot(111) + QueueFigurePlot.set_xlabel('Time [s]') + QueueFigurePlot.set_ylabel('Queue Utilization') + QueueFigurePlot.set_title('Average Queue Utilization: ' + str(basename)) + QueueFigurePlot.grid(True) + + + for b in range(bufferNumber): + cursor.execute("select Time, AverageBufferDepth from BufferDepth where BufferNumber = {};".format(b)) + time = [None] * steps + queue = [None] * steps + for i in range(steps-1): + result = cursor.fetchone() + time[i] = result[0] + queue[i] = result[1] + + QueueFigurePlot.plot(time, queue, linewidth=0.5, label="Queue {}".format(b)) + + QueueFigurePlot.legend(loc="upper left") + + x1,x2,y1,y2 = QueueFigurePlot.axis() + QueueFigurePlot.axis((x1,x2,0,maxBufferDepth)) + + pdf = PdfPages(outputFileName) + pdf.savefig(QueueFigure) + pdf.close() + QueueFigurePlot.clear() + plt.close() + + return outputFile @plot def power_window(connection, tracePath, steps): @@ -252,7 +301,6 @@ def power_window(connection, tracePath, steps): return outputFile -@plot def latency_analysis(connection, tracePath, steps): from collections import Counter query = """ SELECT ((p2.PhaseEnd - p1.PhaseBegin)/1000), t.id