1
0
Fork 0

chore(minigames): log Bomperator transport kind and raw ping samples in debug stats

The rtt fields in __bompDbg.stats() are the smoothed EMA (seeded at 100ms,
one WS sample per 2s), so short playtests read as 35ms+ even on a 5ms path.
Record every raw RTT sample and the active transport (logged on mount, not
only on fallback) so the next playtest shows the real numbers.
This commit is contained in:
Jason Fraley 2026-10-21 20:50:40 -04:00
parent 54efc9453f
commit 59460111fd

View file

@ -57,6 +57,10 @@ const BOMP_DEBUG =
}
})();
/** Raw transport readings for the debug stats: every RTT sample as measured
* (not the smoothed EMA the rows carry) and the transport actually in use. */
const dbgTransport: { pings: number[]; kind: string } = { pings: [], kind: "unknown" };
interface DbgRow {
/** ms since page epoch (performance.now at record). */
t: number;
@ -511,6 +515,11 @@ export function BomperatorGame({
ghostRows: r.filter((x) => x.gh > 0).length,
rttMin: r.length ? Math.min(...r.map((x) => x.r)) : 0,
rttMax: r.length ? Math.max(...r.map((x) => x.r)) : 0,
transport: dbgTransport.kind,
pingN: dbgTransport.pings.length,
pingP50: pct(dbgTransport.pings, 0.5),
pingP95: pct(dbgTransport.pings, 0.95),
pingMax: dbgTransport.pings.length ? Math.max(...dbgTransport.pings) : 0,
};
console.table(out);
return out;
@ -576,13 +585,22 @@ export function BomperatorGame({
() =>
transport.onRttSample((ms) => {
rttAvgRef.current = rttAvgRef.current * 0.8 + ms * 0.2;
if (BOMP_DEBUG) {
dbgTransport.pings.push(Math.round(ms));
if (dbgTransport.pings.length > 1000) dbgTransport.pings.shift();
}
}),
[transport],
);
useEffect(() => {
if (!BOMP_DEBUG) return undefined;
const off = transport.onKindChange?.((k) => console.info(`[bompDbg] transport kind -> ${k}`));
dbgTransport.kind = transport.kind;
console.info(`[bompDbg] transport kind = ${transport.kind}`);
const off = transport.onKindChange?.((k) => {
dbgTransport.kind = k;
console.info(`[bompDbg] transport kind -> ${k}`);
});
return () => off?.();
}, [transport]);