Lag Detector
Scope
- •Profiling: Statistical sampling of CPU execution.
- •Hotspot Analysis: Identify which routines consume the most cycles.
- •Source Mapping: Map hotspots back to ASM files.
Core Capabilities
1. Profile execution
- •
run --duration 10: Sample CPU for 10 seconds. - •Output: A heatmap of the most executed routines.
2. Identify Bottlenecks
- •"Routine
Update_Spritesexecuted 5000 times (40% of samples)." - •Helps pinpoint inefficient loops or heavy logic.
Workflow
- •Setup: Navigate to a laggy area (e.g., room with many enemies).
- •Profile:
lag-detector run --duration 5. - •Analyze: "Top hotspot is
Sprite_DrawinSprites.asm."
Dependencies
- •Tool:
~/src/hobby/yaze/scripts/ai/profiler.py. - •Mesen2: Running with socket server.
- •z3ed: For symbol resolution.
Example Prompts
- •"Profile the game for 10 seconds to find lag sources."
- •"What routine is taking up the most CPU time right now?"
Troubleshooting
- •No Hotspots: Ensure the game is not paused.
- •Unknown Symbols: Ensure the ROM has a valid
.mlborsourcemap.json.