feat(timer): show start/end address of profiled region

This commit is contained in:
shokre 2021-11-19 20:29:25 +01:00
parent 0d3c3c28a0
commit 4f40aaa7b2

View file

@ -1,11 +1,14 @@
timer = {} timer = {}
timer_pos = {}
def mem_listener(addr, val, cpu): def mem_listener(addr, val, cpu):
if addr >= 0xa000 and addr <= 0xa0ff: if addr >= 0xa000 and addr <= 0xa0ff:
timer_ix = addr & 0xff timer_ix = addr & 0xff
if timer_ix in timer: if timer_ix in timer:
print('timer(%s):duration %d cy' % (timer_ix, cpu.cycles - timer[timer_ix] - 4)) print('timer(%3d:%04x-%04x):duration %d cy' % (timer_ix, timer_pos[timer_ix], cpu.pc-1, cpu.cycles - timer[timer_ix] - 4))
del timer[timer_ix] del timer[timer_ix]
del timer_pos[timer_ix]
else: else:
timer[timer_ix] = cpu.cycles timer[timer_ix] = cpu.cycles
timer_pos[timer_ix] = cpu.pc+2