From eba03924870cff7edf21af9149db00b2b93ed1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 2 Aug 2018 18:39:27 +0200 Subject: [PATCH] [Metrics]: new metrics Count all commands requests and responses. Other changes: - Code quality, redability and reusability improved. --- DRAMSys/traceAnalyzer/scripts/memUtil.py | 20 ++++ DRAMSys/traceAnalyzer/scripts/metrics.py | 136 ++++++++++++++++------- 2 files changed, 115 insertions(+), 41 deletions(-) diff --git a/DRAMSys/traceAnalyzer/scripts/memUtil.py b/DRAMSys/traceAnalyzer/scripts/memUtil.py index 958aa0e1..4a11df45 100755 --- a/DRAMSys/traceAnalyzer/scripts/memUtil.py +++ b/DRAMSys/traceAnalyzer/scripts/memUtil.py @@ -96,3 +96,23 @@ def getControllerThread(connection): cursor.execute("SELECT ControllerThread FROM GeneralInfo") result = cursor.fetchone() return result[0] + +def get_phase_occurrences(connection, phase): + cursor = connection.cursor() + query = "select count(*) from Phases where PhaseName = :phase" + cursor.execute(query, {"phase": phase}) + r = cursor.fetchone() + cnt = r[0] + if (cnt is None): + cnt = 0 + return cnt + +def get_total_time_in_phase(connection, phase): + cursor = connection.cursor() + query = "select sum(PhaseEnd - PhaseBegin) / 1000 from Phases where PhaseName = :phase" + cursor.execute(query, {"phase": phase}) + time = cursor.fetchone() + totalTime = time[0] + if (totalTime is None): + totalTime = 0.0 + return totalTime diff --git a/DRAMSys/traceAnalyzer/scripts/metrics.py b/DRAMSys/traceAnalyzer/scripts/metrics.py index fed580c6..feebd957 100644 --- a/DRAMSys/traceAnalyzer/scripts/metrics.py +++ b/DRAMSys/traceAnalyzer/scripts/metrics.py @@ -27,14 +27,6 @@ def getThreads(connection): result.append(currentRow[0]) return result -# @metric -# def average_response_latency_in_ns(connection): -# cursor = connection.cursor() -# cursor.execute("""SELECT avg(PhaseBegin-timeOfGeneration)/1000 FROM transactions INNER JOIN Phases ON phases.transact = transactions.ID WHERE PhaseName='RESP' """) -# -# result = cursor.fetchone() -# return round(result[0],1) - @metric def trace_length_in_ns(connection): @@ -217,27 +209,108 @@ def thread_conclusion_in_ns(connection, thread): @metric -def number_of_activates(connection): - cursor = connection.cursor() - cursor.execute("SELECT COUNT(*) FROM Phases WHERE PhaseName = 'ACT'") - result = cursor.fetchone() - return result[0] +def REQ_count(connection): + return get_phase_occurrences(connection, 'REQ') + + +@metric +def RESP_count(connection): + return get_phase_occurrences(connection, 'RESP') + + +@metric +def PREB_count(connection): + return get_phase_occurrences(connection, 'PREB') + + +@metric +def PRE_count(connection): + return get_phase_occurrences(connection, 'PRE') + + +@metric +def ACTB_count(connection): + return get_phase_occurrences(connection, 'ACTB') + + +@metric +def ACT_count(connection): + return get_phase_occurrences(connection, 'ACT') + + +@metric +def PRE_ALL_count(connection): + return get_phase_occurrences(connection, 'PRE_ALL') + + +@metric +def REFA_count(connection): + return get_phase_occurrences(connection, 'REFA') + + +@metric +def REFB_count(connection): + return get_phase_occurrences(connection, 'REFB') + + +@metric +def RD_count(connection): + return get_phase_occurrences(connection, 'RD') + + +@metric +def RDA_count(connection): + return get_phase_occurrences(connection, 'RDA') + + +@metric +def WR_count(connection): + return get_phase_occurrences(connection, 'WR') + + +@metric +def WRA_count(connection): + return get_phase_occurrences(connection, 'WRA') + + +@metric +def PDNA_count(connection): + return get_phase_occurrences(connection, 'PDNA') + + +@metric +def PDNB_count(connection): + return get_phase_occurrences(connection, 'PDNAB') + + +@metric +def PDNP_count(connection): + return get_phase_occurrences(connection, 'PDNP') + + +@metric +def PDNPB_count(connection): + return get_phase_occurrences(connection, 'PDNPB') + + +@metric +def SREF_count(connection): + return get_phase_occurrences(connection, 'SREF') + + +@metric +def SREFB_count(connection): + return get_phase_occurrences(connection, 'SREFB') @metric def number_of_accesses(connection): - cursor = connection.cursor() - cursor.execute("SELECT COUNT(*) FROM Phases WHERE PhaseName IN ('REQ')") - result = cursor.fetchone() - return result[0] + return REQ_count(connection) @metric -def number_of_refreshes(connection): - cursor = connection.cursor() - cursor.execute("SELECT COUNT(*) FROM Phases WHERE PhaseName = 'REFA'") - result = cursor.fetchone() - return result[0] +def accesses_per_activate(connection): + return round(float(REQ_count(connection)) / ACT_count(connection), 1) @metric @@ -335,25 +408,6 @@ def bank_overlap_ratio(connection): # return result[0] -@metric -def accesses_per_activate(connection): - cursor = connection.cursor() - cursor.execute("SELECT COUNT(*) FROM Phases WHERE PhaseName IN ('REQ')") - result = cursor.fetchone() - return round(result[0]*1.0/number_of_activates(connection), 1) - - -def get_total_time_in_phase(connection, phase): - cursor = connection.cursor() - query = "SELECT SUM(PhaseEnd - PhaseBegin) / 1000 from Phases where PhaseName = :phase" - cursor.execute(query, {"phase": phase}) - time = cursor.fetchone() - totalTime = time[0] - if (totalTime is None): - totalTime = 0.0 - return totalTime - - def time_in_PDNA_in_ns(connection): return get_total_time_in_phase(connection, "PDNA")