From cf2bc85bd1dffda05ad6a239baa3b2c13c769869 Mon Sep 17 00:00:00 2001 From: Matthias Jung Date: Wed, 18 Jan 2017 12:22:46 +0100 Subject: [PATCH] Enabled the Histogram script again --- DRAMSys/analyzer/scripts/plots.py | 54 +++++++++++++++++++------------ 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/DRAMSys/analyzer/scripts/plots.py b/DRAMSys/analyzer/scripts/plots.py index ef672088..8d92fd5f 100755 --- a/DRAMSys/analyzer/scripts/plots.py +++ b/DRAMSys/analyzer/scripts/plots.py @@ -80,16 +80,16 @@ def memory_utilisation_window(connection, tracePath, steps): subplotIndex = 211 plt.subplot(subplotIndex) plt.plot(time, bandwidthPercentage) - plt.xlabel('Time (ns)') - plt.ylabel('Bandwidth (%)') + plt.xlabel('Time [ns]') + plt.ylabel('Bandwidth [%]') plt.ylim(-1, maximumPercentage + (10 - maximumPercentage%10)) plt.grid(True) subplotIndex += 1 plt.subplot(subplotIndex) plt.plot(time, bandwidth) - plt.xlabel('Time (ns)') - plt.ylabel('Bandwidth (Gibit/s)') + plt.xlabel('Time [ns]') + plt.ylabel('Bandwidth [Gibit/s]') plt.ylim((-0.01)*float(maxDataRate)/1024, ((maximumPercentage + (10 - maximumPercentage%10))/100)*float(maxDataRate)/1024) plt.grid(True) @@ -123,7 +123,6 @@ def power_window(connection, tracePath, steps): name = ntpath.basename(tracePath) basename, extension = os.path.splitext(name) - OUTPUT_FILE = 'power_' + basename + '.pdf' outputFile = "\n" + "Output file is {0}".format(OUTPUT_FILE) @@ -131,8 +130,8 @@ def power_window(connection, tracePath, steps): from matplotlib.backends.backend_pdf import PdfPages plt.plot(time, power) - plt.xlabel('Time (ns)') - plt.ylabel('Power (mW)') + plt.xlabel('Time [ns]') + plt.ylabel('Power [mW]') plt.grid(True) pdf = PdfPages(OUTPUT_FILE) pdf.savefig() @@ -140,18 +139,33 @@ def power_window(connection, tracePath, steps): plt.close() return outputFile -# @plot -# def latency_histogram(connection): -# # This function plots an histogram with access latencys -# cursor = connection.cursor() -# cursor.execute("SELECT ((p2.PhaseEnd - p1.PhaseEnd)/1000) FROM Transactions t, Phases p1, Phases p2 WHERE t.id = p1.Transact and t.id = p2.Transact and p1.PhaseName = \"REQ\" and p2.PhaseName = \"RESP\" ") -# result = cursor.fetchall() -# #result.sort() -# #print(max(result)[0]) -# import matplotlib.pyplot as plt -# plt.hist(result, bins=max(result)[0], histtype='barstacked') -# plt.savefig('hist.png') -# return "Saved as hist.png" +@plot +def latency_histogram(connection, tracePath, steps): + # This function plots an histogram with access latencys + outputFile = "" + cursor = connection.cursor() + cursor.execute("SELECT ((p2.PhaseEnd - p1.PhaseEnd)/1000) FROM Transactions t, Phases p1, Phases p2 WHERE t.id = p1.Transact and t.id = p2.Transact and p1.PhaseName = \"REQ\" and p2.PhaseName = \"RESP\" ") + result = cursor.fetchall() + + name = ntpath.basename(tracePath) + basename, extension = os.path.splitext(name) + + OUTPUT_FILE = 'hist_' + basename + '.pdf' + outputFile = "\n" + "Output file is {0}".format(OUTPUT_FILE) + + numberOfBins=50 + + import matplotlib.pyplot as plt + from matplotlib.backends.backend_pdf import PdfPages + plt.hist(result, bins=numberOfBins, histtype='barstacked', facecolor='green') + plt.grid(True) + plt.xlabel("Access Time [ns]") + plt.ylabel("Number (Frequency)") + pdf = PdfPages(OUTPUT_FILE) + pdf.savefig() + pdf.close() + plt.close() + return outputFile def generatePlots(pathToTrace): @@ -169,7 +183,7 @@ def generatePlots(pathToTrace): else: cursor.execute(" SELECT TraceEnd FROM GeneralInfo ") traceEnd = float(cursor.fetchone()[0]) - steps = ceil(traceEnd/windowSize) + steps = int(ceil(traceEnd/windowSize)) for p in plots: outputFiles += p(connection, pathToTrace, steps)