Skip to content

Instantly share code, notes, and snippets.

@boochow
Last active May 4, 2018 16:31
Show Gist options
  • Save boochow/7ac60b9a4f489fe5ae36bcd5d44177bf to your computer and use it in GitHub Desktop.
Save boochow/7ac60b9a4f489fe5ae36bcd5d44177bf to your computer and use it in GitHub Desktop.
import machine, utime
log = []
def add_log(t):
global log
log.append((utime.ticks_us() & 0xffffffff) + 1000 - t.compare_register())
times = 1000
tim = machine.Timer(3)
tim.init(period=1000,mode=tim.PERIODIC,callback=lambda t:add_log(t))
while(tim.counter() < times + 1):
pass
tim.deinit()
for i in range(min(log),max(log) + 1):
print(i, log.count(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment