"""Where the SH-2s spend the boot: PC histogram (sampled every 1,000 steps) per 10 frames.""" import sys from collections import Counter from sega32x_python.runner import Session cart, last = sys.argv[1], int(sys.argv[2]) s = Session.start(cart, "/data/emu/images/x55/bios") side = s.device.sh2 hist = [Counter(), Counter()] count = [0] def step(index, chip): count[0] += 1 if count[0] % 1000 == 0: hist[index][chip.pc & ~0x1F] += 1 # 32-byte bins side.on_step = step for frame in range(1, last + 1): s.run_frame() if frame % 10 == 0: for i, name in enumerate(("master", "slave")): top = ", ".join(f"{pc:08X}:{n}" for pc, n in hist[i].most_common(4)) print(f"frame {frame} {name}: {top}", flush=True) hist = [Counter(), Counter()]