Improvement

Reusing code instead of replicating it.
This commit is contained in:
Éder F. Zulian
2018-08-02 15:35:49 +02:00
parent 9a4f8eda1e
commit d0f500119e

View File

@@ -73,10 +73,8 @@ def memory_active(connection):
cursor = connection.cursor()
cursor.execute(""" SELECT sum(DataStrobeEnd - DataStrobeBegin) FROM transactions """)
active = cursor.fetchone()
cursor = connection.cursor()
cursor.execute(""" SELECT clk FROM GeneralInfo """)
clk = cursor.fetchone()
return (active[0]/clk[0])
clk, unit = getClock(connection)
return (active[0]/clk)
@metric
@@ -84,10 +82,8 @@ def memory_total(connection):
cursor = connection.cursor()
cursor.execute(""" SELECT max(DataStrobeEnd) FROM Transactions """)
total = cursor.fetchone()
cursor = connection.cursor()
cursor.execute(""" SELECT clk FROM GeneralInfo """)
clk = cursor.fetchone()
return (total[0]/clk[0])
clk, unit = getClock(connection)
return (total[0]/clk)
@metric
@@ -95,13 +91,11 @@ def memory_idle(connection):
cursor = connection.cursor()
cursor.execute(""" SELECT sum(p1.PhaseEnd - p2.PhaseBegin) FROM Phases p1, Phases p2 Where p1.PhaseName = "REQ" and p2.PhaseName = "RESP" and ((p1.Transact-1) = (p2.Transact)) and (p1.PhaseEnd > p2.PhaseBegin) """)
idle = cursor.fetchone()
cursor = connection.cursor()
cursor.execute(""" SELECT clk FROM GeneralInfo """)
clk = cursor.fetchone()
if (idle[0] is None):
return 0
else:
return (idle[0]/clk[0])
clk, unit = getClock(connection)
return (idle[0]/clk)
@metric
@@ -249,14 +243,12 @@ def number_of_refreshes(connection):
@metric
def bank_overlap_ratio(connection):
# Calculates how many banks are open in parallel
cursor = connection.cursor()
cursor.execute("SELECT clk FROM GeneralInfo ")
clk = cursor.fetchone()
clk, unit = getClock(connection)
cursor = connection.cursor()
cursor.execute("select TraceEnd from GeneralInfo")
traceEndTMP = cursor.fetchone()
traceEnd = int(traceEndTMP[0]/clk[0])
traceEnd = int(traceEndTMP[0]/clk)
trace = []
cursor.execute("""
@@ -269,7 +261,7 @@ def bank_overlap_ratio(connection):
prevTime = 0
for c in cursor:
trace.append([(int(c[0]/clk[0])), c[1]])
trace.append([(int(c[0]/clk)), c[1]])
# Insert a pseudo precharge all to mark the end of the trace
trace.append([traceEnd, "PRE_ALL"])