[Metrics]: new metrics
Count all commands requests and responses. Other changes: - Code quality, redability and reusability improved.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user