mirror of
https://github.com/D-Modem/courier-emu.git
synced 2026-11-28 20:38:07 -08:00
courier_c5x_get_io_port_stats answered every query by walking the whole m_io_events vector once per port. That vector is only cleared at reset, so the scan was linear in the length of the run, and the bridge's ROM-load and overlay-commit loops ask for the stats once per single-step: the cost of committing a block grew with how much had already been committed. Keep the six figures per port in IO_READ16 and IO_WRITE16 instead, the way m_data_write_counts already does for data writes, and make the query an array lookup. Replaying the event log over a five-million-instruction run reproduces the new counters exactly, and a twenty-million-instruction run of MAIN_2.3.31 gives byte-identical output. At 139k events the sixteen-port query drops from 599us to 21us and stops growing; a step(1) loop that samples one port goes from 0.12 to 0.52M instructions per second. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>