hmm
This commit is contained in:
parent
d5c661bc22
commit
9ef1b8dbb1
23 changed files with 329 additions and 96 deletions
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
Object.defineProperties(World.prototype, Object.getOwnPropertyDescriptors({
|
||||
performanceLevel() {
|
||||
if (window.TarinaiPerformance) return window.TarinaiPerformance.level || 0;
|
||||
if (window.TarinaiPerformance) return window.TarinaiPerformance.quality?.(this)?.level || window.TarinaiPerformance.level || 0;
|
||||
const fps = typeof window !== "undefined" ? Number(window.__tarinaiFps || 0) : 60;
|
||||
if (!fps || !Number.isFinite(fps)) return 0;
|
||||
if (fps < 22) return 3;
|
||||
|
|
@ -25,12 +25,51 @@
|
|||
return window.TarinaiPerformance?.quality?.(this) || { level: this.performanceLevel(), antStride: 1, effectLimit: CONFIG.effectLimit ?? 96 };
|
||||
},
|
||||
|
||||
beginFramePerformanceBudgets(quality = this.performanceQuality?.()) {
|
||||
const pressure = clamp(Number(quality?.pressure || 0) || 0, 0, 1);
|
||||
const density = clamp(Number(quality?.effectDensity || (1 - pressure)) || 0, 0.12, 1);
|
||||
this.workBudget = {
|
||||
ai: Math.max(4, Math.round(4 + density * 24)),
|
||||
env: Math.max(3, Math.round(3 + density * 15)),
|
||||
aiUsed: 0,
|
||||
envUsed: 0,
|
||||
};
|
||||
this.workStats = {
|
||||
aiRuns: 0,
|
||||
aiSkips: 0,
|
||||
envRuns: 0,
|
||||
envSkips: 0,
|
||||
collisionRuns: 0,
|
||||
collisionSkips: 0,
|
||||
bedConflictRuns: 0,
|
||||
bedConflictSkips: 0,
|
||||
};
|
||||
},
|
||||
|
||||
spendScheduledWork(kind = "ai", urgent = false) {
|
||||
if (!this.workBudget) this.beginFramePerformanceBudgets?.();
|
||||
const stats = this.workStats || {};
|
||||
const budget = this.workBudget || {};
|
||||
const usedKey = `${kind}Used`;
|
||||
const runKey = `${kind}Runs`;
|
||||
const skipKey = `${kind}Skips`;
|
||||
if (urgent || (budget[usedKey] || 0) < (budget[kind] || 0)) {
|
||||
budget[usedKey] = (budget[usedKey] || 0) + 1;
|
||||
stats[runKey] = (stats[runKey] || 0) + 1;
|
||||
return true;
|
||||
}
|
||||
stats[skipKey] = (stats[skipKey] || 0) + 1;
|
||||
return false;
|
||||
},
|
||||
|
||||
runtimeDiagnostics() {
|
||||
const behaviorCounts = {};
|
||||
let forcedBehaviors = 0;
|
||||
let lockedBehaviors = 0;
|
||||
let liveTarinai = 0;
|
||||
for (const t of this.tarinai || []) {
|
||||
if (!t || t.dead) continue;
|
||||
liveTarinai += 1;
|
||||
const behavior = typeof currentTarinaiBehavior === "function" ? currentTarinaiBehavior(t) : t.behavior;
|
||||
const id = behavior?.id || t.state || "none";
|
||||
behaviorCounts[id] = (behaviorCounts[id] || 0) + 1;
|
||||
|
|
@ -65,6 +104,18 @@
|
|||
locked: lockedBehaviors,
|
||||
counts: behaviorCounts,
|
||||
},
|
||||
performance: {
|
||||
liveTarinai,
|
||||
fps: window.TarinaiPerformance?.fps || window.__tarinaiFps || 0,
|
||||
pressure: this.performanceQuality?.().pressure || 0,
|
||||
level: this.performanceLevel?.() || 0,
|
||||
dpr: (typeof uiCache !== "undefined" ? uiCache?.canvasDpr : window.uiCache?.canvasDpr) || 0,
|
||||
quality: this.performanceQuality?.() || null,
|
||||
},
|
||||
work: {
|
||||
budget: this.workBudget || null,
|
||||
stats: this.workStats || null,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue