bachelorThesis/machine_time_waste/statuses-total-time.py

59 lines
1.6 KiB
Python

# vim: set ts=2 sw=2 et tw=80:
# Sums the times instances spend in one of each states in the diagram saved as
# "statuses.drawio". Unknown times are summed as "unknown"
import json
import sys
# QUEUE = set(["0-2", "1-2", "assumptions:", "1-1", "1-0"])
# RESUB = set(["4-1", "4-0", "5-1", "6-1", "7-1", "8-1", "assumptions:", "5-0", "6-0", "7-0", \
# "8-0"])
# READY = set(["0-3", "2-3", "0-9", "2-9", "9-3", "2-7", "2-8", "9-7", "9-8", \
# "9-9", "0-7", "0-8", "assumptions:", "2-0", "2-4", "9-4", "9-1"])
# RUN = set(["3-1", "3-10", "3-4", "3-5", "3-6", "3-7", "3-8", "10-5", "10-6", \
# "10-7", "10-8", "10-4", "10-10", "10-1", "assumptions:", "3-0", "10-0", "3-3"])
QUEUE = set(["0-2", "1-2"])
ENDED = set(["5-1", "6-1", "7-1", "8-1"])
READY = set(["0-3", "0-9", "2-3", "2-9", "9-3", "9-9"])
RUN = set(["3-1", "3-4", "3-5", "3-6", "3-7", "3-8", "3-10", "10-1", "10-4", "10-5", "10-6", "10-7", "10-8", "10-10"])
EVICT = set(["4-1", "4-0"])
obj = {}
with open(sys.argv[1], 'r') as f:
obj = json.loads(f.read())
for pair in obj["data"]:
s = set()
qt = et = rt = xt = vt = ut = 0
print("End type " + str(pair[0]))
x = pair[1]
for k in x.keys():
if k in QUEUE:
qt += x[k]
elif k in ENDED:
et += x[k]
elif k in READY:
rt += x[k]
elif k in RUN:
xt += x[k]
elif k in EVICT:
vt += x[k]
else:
s.add(k)
ut += x[k]
print("Queued: \t" + str(qt))
print("Ended: \t" + str(et))
print("Ready: \t" + str(rt))
print("Running:\t" + str(xt))
print("Evicted:\t" + str(vt))
print("Unknown:\t" + str(ut))
print(s)