aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2022-05-25 10:29:08 +0000
committers-ol <s+removethis@s-ol.nu>2022-05-25 10:29:08 +0000
commit8860d097705aaac93beaaa4ccb09cf2d646228a9 (patch)
tree53b7eda891f6eaf356b7a41125dc356f02c9478f
parentperf: less OLED redraws in base (diff)
downloadfirmware-8860d097705aaac93beaaa4ccb09cf2d646228a9.tar.gz
firmware-8860d097705aaac93beaaa4ccb09cf2d646228a9.zip
add debug module for timings
-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")