Skip to content

Commit

Permalink
topdiff: Add PSI stats
Browse files Browse the repository at this point in the history
Signed-off-by: iipeace <[email protected]>
  • Loading branch information
iipeace committed Oct 4, 2024
1 parent 0263b58 commit 1faf8f9
Showing 1 changed file with 44 additions and 21 deletions.
65 changes: 44 additions & 21 deletions guider/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__credits__ = "Peace Lee"
__license__ = "GPLv2"
__version__ = "3.9.8"
__revision__ = "241003"
__revision__ = "241004"
__maintainer__ = "Peace Lee"
__email__ = "[email protected]"
__repository__ = "https://github.com/iipeace/guider"
Expand Down Expand Up @@ -116868,7 +116868,7 @@ def _getProcName(pinfo):
def _getter(func, var):
return [
func([i[0] for i in var]),
func([i[1] for i in var]),
func([i[1] if len(i) > 1 else i[0] for i in var]),
]

def _updateStats(target, usage):
Expand Down Expand Up @@ -116983,8 +116983,26 @@ def _updateStats(target, usage):
if not stats:
continue
elif r in ("psiUsage"):
# TODO: handle PSI usage #
continue
itemList = []
for res, subStats in stats.items():
subStats = [
list(map(long, x.split("/")))
for x in subStats.split()
]
subStats = _getter(lambda x: x, subStats)
rname = "psi" + res[0].upper() + res[1:]
itemList.append(
(
rname + "Some",
subStats[0],
)
)
itemList.append(
(
rname + "Full",
subStats[1],
)
)
elif r in ("nrTask"):
subStats = [list(map(long, x.split("/"))) for x in stats]
subStats = _getter(lambda x: x, subStats)
Expand Down Expand Up @@ -117536,9 +117554,11 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
if unit:
newStatStr = "%7s(%2d)(%4s%s/%6.1f%s/%4s%s/%5s%s) |"
diffStr = "{0:>6}{1:1}"
diffStr2 = "%6.1f%s"
else:
newStatStr = "%7s(%2d)(%5s%s/%7.1f%s/%5s%s/%6s%s) |"
diffStr = "{0:>7}{1:0}"
diffStr2 = "%7.1f%s"
jsonData[res] = {}

# print diff #
Expand All @@ -117565,7 +117585,9 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
nrPrint = 0

for pname, value in sorted(
unionList.items(), key=lambda e: float(e[1]), reverse=True
unionList.items(),
key=lambda e: (float(e[1]), e[0]),
reverse=True,
):
if pname == "[ TOTAL ]":
continue
Expand Down Expand Up @@ -117595,8 +117617,9 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
# no target process in this file #
if not pname in procList:
if idx > 0 and pname in prevProcList:
diff = "%6.1f%s" % (
-(prevProcList[pname][item]),
diffVal = prevProcList[pname][item]
diff = diffStr2 % (
-(diffVal) if diffVal else 0,
unit,
)
diff = convColor(diff, "WARNING", 6)
Expand Down Expand Up @@ -117632,11 +117655,9 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
else:
diff = "0"

total = convNum(procStat["total"])

jsonData[res][pname][fname] = {
"diff": diff.strip(" %"),
"total": total,
"total": procStat["total"],
"cnt": procStat["cnt"],
"min": procStat["minimum"],
"avg": procStat["average"],
Expand All @@ -117646,13 +117667,13 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
newStat = newStatStr % (
diff,
procStat["cnt"],
procStat["minimum"],
convNum(procStat["minimum"]),
unit,
procStat["average"],
unit,
procStat["maximum"],
convNum(procStat["maximum"]),
unit,
total,
convNum(procStat["total"]),
unit,
)

Expand Down Expand Up @@ -117736,7 +117757,7 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
nrPrint = 0

for pname, value in sorted(
unionBlkList.items(), key=lambda e: sum(e[1]), reverse=True
unionBlkList.items(), key=lambda e: (sum(e[1]), e[0]), reverse=True
):
if pname == "[ TOTAL ]":
continue
Expand Down Expand Up @@ -117896,7 +117917,9 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
nrPrint = 0

for pname, value in sorted(
unionRssList.items(), key=lambda e: long(e[1]), reverse=True
unionRssList.items(),
key=lambda e: (long(e[1]), e[0]),
reverse=True,
):
if pname == "FREE":
printBuf = "%16s | " % "[FREE]"
Expand Down Expand Up @@ -118090,9 +118113,9 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
if initDiff:
initDiffStr = convNum(initDiff, True, 1)
if initDiff > 0:
initDiff = convColor(initDiffStr, "RED")
initDiff = convColor(initDiffStr, "RED", 5)
elif initDiff < 0:
initDiff = convColor(initDiffStr, "GREEN")
initDiff = convColor(initDiffStr, "GREEN", 5)
else:
initDiff = "-"
diff = "%5s(%5s)/%5s(%5s) |" % (
Expand Down Expand Up @@ -118158,9 +118181,9 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
if "startDiff" in sdUnitStat:
startDiff = convNum(sdUnitStat["startDiff"], True, 1)
if sdUnitStat["startDiff"] > 0:
startDiff = convColor(startDiff, "RED")
startDiff = convColor(startDiff, "RED", 5)
elif sdUnitStat["startDiff"] < 0:
startDiff = convColor(startDiff, "GREEN")
startDiff = convColor(startDiff, "GREEN", 5)

if sortStd == "startDiff":
totalerr += abs(sdUnitStat["startDiff"])
Expand All @@ -118170,9 +118193,9 @@ def _getFileMenu(printBuf, menuBuf, menuStat, lenStat):
if "initDiff" in sdUnitStat:
initDiff = convNum(sdUnitStat["initDiff"], True, 1)
if sdUnitStat["initDiff"] > 0:
initDiff = convColor(initDiff, "RED")
initDiff = convColor(initDiff, "RED", 5)
elif sdUnitStat["initDiff"] < 0:
initDiff = convColor(initDiff, "GREEN")
initDiff = convColor(initDiff, "GREEN", 5)

if sortStd != "startDiff":
totalerr += abs(sdUnitStat["initDiff"])
Expand Down

0 comments on commit 1faf8f9

Please sign in to comment.