Changed Delay Reason to RW, WR and Other

This commit is contained in:
Matthias Jung
2020-12-01 21:10:54 +01:00
parent a2ae5f8f49
commit 9355e03012

View File

@@ -131,26 +131,6 @@ def memory_delayed(connection):
idle = memory_idle(connection)
return total - active - idle
def check_miss(connection, ID):
cursor = connection.cursor()
query = """SELECT * FROM phases WHERE PhaseName == "ACT" AND Transact = {};""".format(ID)
cursor.execute(query)
result = cursor.fetchone()
if(result != None) :
return True
else:
return False
def check(connection, gapBegin, gapEnd, b, e):
cursor = connection.cursor()
query = """SELECT Command FROM Transactions WHERE ID = {};""".format(gapBegin)
cursor.execute(query)
begin = cursor.fetchone()[0]
query = """SELECT Command FROM Transactions WHERE ID = {};""".format(gapEnd)
cursor.execute(query)
end = cursor.fetchone()[0]
return (begin == b and end == e)
@metric
def delayed_reasons(connection):
cursor = connection.cursor()
@@ -166,7 +146,10 @@ def delayed_reasons(connection):
ROW_NUMBER () OVER (ORDER BY t.DataStrobeBegin) RowNum,
t.ID as ID,
t.DataStrobeBegin as Begin,
t.DataStrobeEnd as End
t.DataStrobeEnd as End,
t.TRow as Row,
t.TBank as Bank,
t.Command as Command
FROM
Transactions t
@@ -185,11 +168,11 @@ def delayed_reasons(connection):
CREATE TEMPORARY TABLE phasesInOrder AS
SELECT
ROW_NUMBER () OVER (ORDER BY q.PhaseBegin) RowNum,
p.Transact AS ID,
p.PhaseBegin AS BeginRequest,
p.PhaseEnd AS EndRequest,
q.PhaseBegin AS BeginResponse,
q.PhaseEnd AS EndResponse,
p.Transact AS ID
q.PhaseEnd AS EndResponse
FROM
Phases p,
Phases q
@@ -222,11 +205,18 @@ def delayed_reasons(connection):
query = """
CREATE TEMPORARY TABLE delayedDataBusGaps AS
SELECT a.ID AS gapBeginID, b.ID AS gapEndID
SELECT
a.ID AS gapBeginID,
b.ID AS gapEndID,
a.Row AS gapBeginRow,
b.Row AS gapEndRow,
a.Bank AS gapBeginBank,
b.Bank AS gapEndBank,
a.Command AS gapBeginCommand,
b.Command AS gapEndCommand
FROM
dataStrobesInOrder a,
dataStrobesInOrder b
dataStrobesInOrder b
WHERE
(a.RowNum) = (b.RowNum-1) AND
b.Begin > a.End AND
@@ -234,50 +224,45 @@ def delayed_reasons(connection):
"""
cursor.execute(query)
query = """ SELECT * FROM delayedDataBusGaps; """;
# Count RW
query = """
SELECT
COUNT(*)
FROM delayedDataBusGaps
WHERE
gapBeginCommand = "R" AND
gapEndCommand = "W";
""";
cursor.execute(query)
RW = cursor.fetchone()[0]
records = cursor.fetchall()
# Count WR
query = """
SELECT
COUNT(*)
FROM delayedDataBusGaps
WHERE
gapBeginCommand = "W" AND
gapEndCommand = "R";
""";
cursor.execute(query)
WR = cursor.fetchone()[0]
RR_Miss = 0
WW_Miss = 0
RW_Hit = 0
RW_Miss = 0
WR_Hit = 0
WR_Miss = 0
e = 0
result = ""
# Count All Gaps
query = """
SELECT
COUNT(*)
FROM delayedDataBusGaps;
""";
cursor.execute(query)
total = cursor.fetchone()[0]
other = total - RW - WR
for row in records:
gapBegin = row[0]
gapEnd = row[1]
RW /= total / 100.0
WR /= total / 100.0
other /= total / 100.0
if (check(connection, gapBegin, gapEnd, "R", "R") and check_miss(connection, gapEnd)):
RR_Miss += 1
elif(check(connection, gapBegin, gapEnd, "W", "W") and check_miss(connection, gapEnd)):
WW_Miss += 1
elif(check(connection, gapBegin, gapEnd, "R", "W") and (not check_miss(connection, gapEnd))):
RW_Hit += 1
elif(check(connection, gapBegin, gapEnd, "R", "W") and check_miss(connection, gapEnd)):
RW_Miss += 1
elif(check(connection, gapBegin, gapEnd, "W", "R") and (not check_miss(connection, gapEnd))):
WR_Hit += 1
elif(check(connection, gapBegin, gapEnd, "W", "R") and check_miss(connection, gapEnd)):
WR_Miss += 1
else:
print ("ERROR: This should not happen")
exit(-1)
total = RR_Miss + WW_Miss + RW_Hit + RW_Miss + WR_Hit + WR_Miss
RR_Miss /= total
WW_Miss /= total
RW_Hit /= total
RW_Miss /= total
WR_Hit /= total
WR_Miss /= total
result = "RRM: {}, WWM: {}, RWH: {}, RWM: {}, WRH: {}, WRM: {}".format(RR_Miss, WW_Miss, RW_Hit, RW_Miss, WR_Hit, WR_Miss);
result = "RW: {}, WR: {}, Other: {}".format(RW, WR, other);
return result
@metric