import time class TimeStamp: keys: [str] values: [int] total: int def __init__(self): self.keys = [] self.values = [] self.total = 0 def save(self, key: str): tm = time.time() self.keys.append(key) self.values.append(tm) def info(self): lastKey = None lastValue = None msg: [str] = [] for i in enumerate(self.keys): k = self.keys[i[0]] v = self.values[i[0]] if lastValue is None: lastKey = k lastValue = v else: use = round(v - lastValue, 4) msg.append(k + " -> " + lastKey + " use " + str(use)) lastKey = k lastValue = v self.total += use msg.append("total: " + str(self.total)) for s in msg: print(s)