From faababba16f98552dc11b1fe918b4a7480fa6421 Mon Sep 17 00:00:00 2001 From: Felipe Salerno Prado Date: Fri, 18 Mar 2016 17:06:49 +0100 Subject: [PATCH] Power over time charts --- DRAMSys/analyzer/scripts/plots.py | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/DRAMSys/analyzer/scripts/plots.py b/DRAMSys/analyzer/scripts/plots.py index 5eb3b463..745ad8c2 100644 --- a/DRAMSys/analyzer/scripts/plots.py +++ b/DRAMSys/analyzer/scripts/plots.py @@ -72,6 +72,8 @@ def memory_utilisation_window(connection, tracePath): name = ntpath.basename(tracePath) basename, extension = os.path.splitext(name) + + OUTPUT_FILE = 'memory_utilization_' + basename + '.pdf' print("Output file is {0}".format(OUTPUT_FILE)) @@ -101,9 +103,45 @@ def memory_utilisation_window(connection, tracePath): pdf = PdfPages(OUTPUT_FILE) pdf.savefig() pdf.close() + plt.close() return +@plot +def power_window(connection, tracePath): + cursor = connection.cursor() + cursor.execute(""" SELECT max(time) FROM Power """) + maxTime = cursor.fetchone() + cursor.execute(""" SELECT min(time) FROM Power WHERE time > 0""") + windowSize = cursor.fetchone() + steps = ceil(float(maxTime[0])/float(windowSize[0])) + cursor.execute(""" SELECT * FROM Power """) + time = [0] * steps + power = [0] * steps + for i in range(steps): + result = cursor.fetchone() + time[i] = int(result[0])/1000 + power[i] = float(result[1]) + + name = ntpath.basename(tracePath) + basename, extension = os.path.splitext(name) + + OUTPUT_FILE = 'power_' + basename + '.pdf' + print("Output file is {0}".format(OUTPUT_FILE)) + + import matplotlib.pyplot as plt + from matplotlib.backends.backend_pdf import PdfPages + + plt.plot(time, power) + plt.xlabel('Time (ns)') + plt.ylabel('Power (mW)') + plt.grid(True) + pdf = PdfPages(OUTPUT_FILE) + pdf.savefig() + pdf.close() + plt.close() + return + # @plot # def latency_histogram(connection): # # This function plots an histogram with access latencys