mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-30 22:26:42 +00:00
tools/mtstats.py: fix percentage calc; fix typos
This commit is contained in:
parent
fe1dd1e8ac
commit
3e1497b98d
@ -49,6 +49,12 @@ class HistoryEvent:
|
|||||||
return(value)
|
return(value)
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
def calc_pct(a, b):
|
||||||
|
if b > 0.0:
|
||||||
|
return (a / b) * 100
|
||||||
|
else:
|
||||||
|
return 0.0
|
||||||
|
|
||||||
def pct_brackets(pct):
|
def pct_brackets(pct):
|
||||||
spct = "%04.1f" % pct
|
spct = "%04.1f" % pct
|
||||||
if float(spct) >= 100.0:
|
if float(spct) >= 100.0:
|
||||||
@ -151,6 +157,9 @@ for event in events:
|
|||||||
for slot in slots:
|
for slot in slots:
|
||||||
for status in slots[slot]["statuses"]:
|
for status in slots[slot]["statuses"]:
|
||||||
if status == "IDLE":
|
if status == "IDLE":
|
||||||
|
if slots[slot]["statuses"]["FAILED"]["enabled"] == True:
|
||||||
|
slots[slot]["statuses"][status]["total"] += (last_active - slots[slot]["statuses"]["FAILED"]["start"])
|
||||||
|
else:
|
||||||
slots[slot]["statuses"][status]["total"] += (last_active - slots[slot]["statuses"][status]["start"])
|
slots[slot]["statuses"][status]["total"] += (last_active - slots[slot]["statuses"][status]["start"])
|
||||||
elif slots[slot]["statuses"][status]["enabled"] == True:
|
elif slots[slot]["statuses"][status]["enabled"] == True:
|
||||||
if status != "FAILED":
|
if status != "FAILED":
|
||||||
@ -161,7 +170,7 @@ for slot in slots:
|
|||||||
|
|
||||||
# Summarise slot data by various criteria
|
# Summarise slot data by various criteria
|
||||||
summary = {}
|
summary = {}
|
||||||
cumaltive_total = 0
|
cumulative_count = cumulative_total = 0
|
||||||
for slot in slots:
|
for slot in slots:
|
||||||
acount = atotal = 0
|
acount = atotal = 0
|
||||||
scount = stotal = 0
|
scount = stotal = 0
|
||||||
@ -180,7 +189,8 @@ for slot in slots:
|
|||||||
for status in slots[slot]["statuses"]:
|
for status in slots[slot]["statuses"]:
|
||||||
ccount += slots[slot]["statuses"][status]["count"]
|
ccount += slots[slot]["statuses"][status]["count"]
|
||||||
ctotal += slots[slot]["statuses"][status]["total"]
|
ctotal += slots[slot]["statuses"][status]["total"]
|
||||||
cumaltive_total += ctotal
|
cumulative_count += ccount
|
||||||
|
cumulative_total += ctotal
|
||||||
|
|
||||||
summary[slot] = {"busy": {"count": acount, "total": atotal},
|
summary[slot] = {"busy": {"count": acount, "total": atotal},
|
||||||
"stalled": {"count": scount, "total": stotal},
|
"stalled": {"count": scount, "total": stotal},
|
||||||
@ -195,12 +205,12 @@ for slot in summary:
|
|||||||
elapsed = (ended - started)
|
elapsed = (ended - started)
|
||||||
|
|
||||||
print("Total Build Time: %s (wall clock)" % secs_to_hms(elapsed, blankzero=False))
|
print("Total Build Time: %s (wall clock)" % secs_to_hms(elapsed, blankzero=False))
|
||||||
print("Accum Build Time: %s (%d slots)\n" % (secs_to_hms(cumaltive_total, blankzero=False), len(slots)))
|
print("Accum Build Time: %s (%d slots)\n" % (secs_to_hms(cumulative_total, blankzero=False), len(slots)))
|
||||||
|
|
||||||
if incomplete:
|
if incomplete:
|
||||||
print("*** WARNING: active slots detected - build may be in progress/incomplete ***\n")
|
print("*** WARNING: active slots detected - build may be in progress/incomplete ***\n")
|
||||||
|
|
||||||
cum_total = cum_count = cum_pct = 0
|
cum_total = 0.0
|
||||||
print("Breakdown by status (all slots):\n")
|
print("Breakdown by status (all slots):\n")
|
||||||
print(" Status Usage ( Pct ) Count State")
|
print(" Status Usage ( Pct ) Count State")
|
||||||
for status in sorted(ALL_STATUSES):
|
for status in sorted(ALL_STATUSES):
|
||||||
@ -211,8 +221,8 @@ for status in sorted(ALL_STATUSES):
|
|||||||
count += slots[slot]["statuses"][status]["count"]
|
count += slots[slot]["statuses"][status]["count"]
|
||||||
total += slots[slot]["statuses"][status]["total"]
|
total += slots[slot]["statuses"][status]["total"]
|
||||||
|
|
||||||
pct = (100 * total / elapsed / len(slots)) if elapsed > 0.0 else 0.0
|
pct = calc_pct(total, cumulative_total)
|
||||||
cum_pct += pct
|
cum_total += total
|
||||||
|
|
||||||
if status in BUSY_STATUSES:
|
if status in BUSY_STATUSES:
|
||||||
stype = "busy"
|
stype = "busy"
|
||||||
@ -221,10 +231,9 @@ for status in sorted(ALL_STATUSES):
|
|||||||
else:
|
else:
|
||||||
stype = ""
|
stype = ""
|
||||||
print(" %-7s %12s %-7s %-5d %-5s" % (status, secs_to_hms(total, blankzero=True), pct_brackets(pct), count, stype))
|
print(" %-7s %12s %-7s %-5d %-5s" % (status, secs_to_hms(total, blankzero=True), pct_brackets(pct), count, stype))
|
||||||
cum_count += count
|
|
||||||
cum_total += total
|
|
||||||
print(" -------------------------------------")
|
print(" -------------------------------------")
|
||||||
print(" %-7s %12s %-7s %-5d" % ("TOTAL", secs_to_hms(cum_total, blankzero=True), pct_brackets(cum_pct), cum_count))
|
print(" %-7s %12s %-7s %-5d" % ("TOTAL", secs_to_hms(cumulative_total, blankzero=True), \
|
||||||
|
pct_brackets(calc_pct(cum_total, cumulative_total)), cumulative_count))
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
print("Peak concurrency: %d out of %d slots\n" % (peak, len(slots)))
|
print("Peak concurrency: %d out of %d slots\n" % (peak, len(slots)))
|
||||||
@ -238,30 +247,25 @@ print("#Rank Slot Usage ( Pct ) | # of Slots Usage ( Pct
|
|||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
busy_total = 0
|
busy_total = 0
|
||||||
busy_pct = 0
|
|
||||||
for rank, slot in enumerate(sorted(summary, key=get_busy_total, reverse=True)):
|
for rank, slot in enumerate(sorted(summary, key=get_busy_total, reverse=True)):
|
||||||
pct = (100 * summary[slot]["busy"]["total"] / elapsed / len(slots)) if elapsed > 0.0 else 0.0
|
pct = calc_pct(summary[slot]["busy"]["total"], cumulative_total)
|
||||||
state = "active" if slots[slot]["isactive"] == True else " "
|
state = "active" if slots[slot]["isactive"] == True else " "
|
||||||
stime = secs_to_hms(summary[slot]["busy"]["total"], blankzero=True)
|
stime = secs_to_hms(summary[slot]["busy"]["total"], blankzero=True)
|
||||||
busy_total += summary[slot]["busy"]["total"]
|
busy_total += summary[slot]["busy"]["total"]
|
||||||
busy_pct += pct
|
|
||||||
lines.append("%s %s %-7s %6s |" % (slot, stime, pct_brackets(pct), state))
|
lines.append("%s %s %-7s %6s |" % (slot, stime, pct_brackets(pct), state))
|
||||||
|
|
||||||
concurrent_total = 0
|
concurrent_total = 0
|
||||||
concurrent_pct = 0.0
|
|
||||||
for rank, concurrentn in enumerate(sorted(concurrency, key=get_concurrent_val, reverse=True)):
|
for rank, concurrentn in enumerate(sorted(concurrency, key=get_concurrent_val, reverse=True)):
|
||||||
concurrent = concurrency[concurrentn]
|
concurrent = concurrency[concurrentn]
|
||||||
pct = (100 * concurrent["total"] / elapsed / len(slots)) if elapsed > 0.0 else 0.0
|
pct = calc_pct(concurrent["total"], cumulative_total)
|
||||||
stime = secs_to_hms(concurrent["total"], blankzero=True)
|
stime = secs_to_hms(concurrent["total"], blankzero=True)
|
||||||
concurrent_total += concurrent["total"]
|
concurrent_total += concurrent["total"]
|
||||||
concurrent_pct += pct
|
|
||||||
lines[rank] += " %02d %s %-7s" % (concurrentn, stime, pct_brackets(pct))
|
lines[rank] += " %02d %s %-7s" % (concurrentn, stime, pct_brackets(pct))
|
||||||
|
|
||||||
for rank, line in enumerate(lines):
|
for rank, line in enumerate(lines):
|
||||||
print(" #%02d %s" % (rank + 1, line))
|
print(" #%02d %s" % (rank + 1, line))
|
||||||
|
|
||||||
bpct = spct = "%04.1f" % pct
|
|
||||||
print("-----------------------------------------+---------------------------------")
|
print("-----------------------------------------+---------------------------------")
|
||||||
print(" TOTALS %s %-7s %s %-7s" %
|
print(" TOTALS %s %-7s %s %-7s" %
|
||||||
(secs_to_hms(busy_total, blankzero=True), pct_brackets(busy_pct),
|
(secs_to_hms(busy_total, blankzero=True), pct_brackets(calc_pct(busy_total, cumulative_total)),
|
||||||
secs_to_hms(concurrent_total, blankzero=True), pct_brackets(concurrent_pct)))
|
secs_to_hms(concurrent_total, blankzero=True), pct_brackets(calc_pct(concurrent_total, cumulative_total))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user