git.s-ol.nu hw/0x33.board/firmware / 8860d09
add debug module for timings s-ol 2 months ago
1 changed file(s) with 22 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 import time
1 times = []
2 names = []
3
4
5 def start():
6 times.clear()
7 names.clear()
8 times.append(time.monotonic_ns())
9
10
11 def step(name):
12 times.append(time.monotonic_ns())
13 names.append(name)
14
15
16 def stop():
17 timestr = ' + '.join(
18 f"{(times[i+1] - times[i]) // 1000000}ms {text}"
19 for i, text in enumerate(names)
20 )
21 print(f"{timestr} = {(times[-1] - times[0]) // 1000000}ms")