Created
July 27, 2019 01:20
-
-
Save LoboLofi/76572f68da6b66ff2d860e2a286f8d50 to your computer and use it in GitHub Desktop.
Measure time and then show some metrics. The Non-Build-Profiler-hard-way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import functools | |
| class tmeasure(object): | |
| dicTimes = {} | |
| initTime = 0 | |
| glbTime = 0 | |
| def __init__(self): | |
| initTime = 0 | |
| @staticmethod | |
| def start(): | |
| tmeasure.initTime = time.time() | |
| @staticmethod | |
| def stop(Message): | |
| elapsed = (time.time() - tmeasure.initTime) | |
| # print(Message) | |
| # print("\t", elapsed, " seconds") | |
| if Message not in tmeasure.dicTimes.keys(): | |
| tmeasure.dicTimes[Message] = 0, 0 | |
| total, count = tmeasure.dicTimes[Message] | |
| tmeasure.dicTimes[Message] = total + elapsed, count + 1 | |
| @staticmethod | |
| def showTimes(): | |
| glbT = 0 | |
| for message in tmeasure.dicTimes.keys(): | |
| total, count = tmeasure.dicTimes[message] | |
| glbT = glbT + total | |
| for message in tmeasure.dicTimes.keys(): | |
| total, count = tmeasure.dicTimes[message] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment