aboutsummaryrefslogtreecommitdiffstats
path: root/hex33board/debug.py
blob: 32e60943d2b09c43354aa6d2ccb367279d7955c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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")