aboutsummaryrefslogtreecommitdiffstats
path: root/hex33board/debug.py
diff options
context:
space:
mode:
Diffstat (limited to 'hex33board/debug.py')
-rw-r--r--hex33board/debug.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/hex33board/debug.py b/hex33board/debug.py
new file mode 100644
index 0000000..499d2c5
--- /dev/null
+++ b/hex33board/debug.py
@@ -0,0 +1,22 @@
+import time
+times = []
+names = []
+
+
+def start():
+ times.clear()
+ names.clear()
+ times.append(time.monotonic_ns())
+
+
+def step(name):
+ times.append(time.monotonic_ns())
+ names.append(name)
+
+
+def stop():
+ timestr = ' + '.join(
+ f"{(times[i+1] - times[i]) // 1000000}ms {text}"
+ for i, text in enumerate(names)
+ )
+ print(f"{timestr} = {(times[-1] - times[0]) // 1000000}ms")