update:优化性能问题

This commit is contained in:
2026-08-17 10:11:28 +08:00
parent 2628a17b3f
commit 63fb4ae85a
15 changed files with 395 additions and 137 deletions
+16
View File
@@ -99,6 +99,8 @@ const SHOT_EFFECT_WAIT_TIMEOUT_MS = 1200;
const AUDIO_TIMEOUT_BASE = 3500;
const AUDIO_TIMEOUT_PER_KEY = 2600;
const AUDIO_TIMEOUT_MAX = 12000;
const RUNTIME_DIAGNOSTIC_INTERVAL_MS = 60000;
let lastRuntimeDiagnosticAt = 0;
const env = computed(() => {
try {
@@ -108,6 +110,19 @@ const env = computed(() => {
}
});
const maybeLogRuntimeStats = () => {
if (env.value !== "develop" && env.value !== "trial") return;
const now = Date.now();
if (now - lastRuntimeDiagnosticAt < RUNTIME_DIAGNOSTIC_INTERVAL_MS) return;
lastRuntimeDiagnosticAt = now;
console.log("[training-runtime]", {
scoreCount: scores.value.length,
renderedTargetShotCount: Math.min(scores.value.length, 12),
renderedScoreCardCount: Math.min(scores.value.length, 60) + 1,
...audioManager.getRuntimeStats(),
});
};
const isDistanceStage = computed(() => pageStage.value === pageStages.DISTANCE);
const isShootingStage = computed(() => pageStage.value === pageStages.SHOOTING);
const hasPractiseResult = computed(() => !!practiseResult.value?.details);
@@ -1111,6 +1126,7 @@ async function onReceiveMessage(msg) {
scores.value = msg.details;
hasNewShot = msg.details.length === previousScoreLength + 1;
latestShot = hasNewShot ? msg.details[msg.details.length - 1] : null;
maybeLogRuntimeStats();
}
if (trainingType.value === "precision") {