mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-07 11:09:34 +00:00
Fix UnitLayer perf counters in prod overlay
This commit is contained in:
@@ -483,11 +483,15 @@ export class GameRenderer {
|
|||||||
|
|
||||||
const tickLayerDurations: Record<string, number> = {};
|
const tickLayerDurations: Record<string, number> = {};
|
||||||
const layerCounters: Record<string, Record<string, number>> = {};
|
const layerCounters: Record<string, Record<string, number>> = {};
|
||||||
|
let unitLayerCounters: Record<string, number> | null = null;
|
||||||
|
|
||||||
for (const layer of this.layers) {
|
for (const layer of this.layers) {
|
||||||
if (!layer.tick) {
|
if (!layer.tick) {
|
||||||
const counters = layer.getPerfCounters?.();
|
const counters = layer.getPerfCounters?.();
|
||||||
if (counters && Object.keys(counters).length > 0) {
|
if (counters && Object.keys(counters).length > 0) {
|
||||||
|
if (layer instanceof UnitLayer) {
|
||||||
|
unitLayerCounters = counters;
|
||||||
|
}
|
||||||
const label = layer.constructor?.name ?? "UnknownLayer";
|
const label = layer.constructor?.name ?? "UnknownLayer";
|
||||||
layerCounters[label] = counters;
|
layerCounters[label] = counters;
|
||||||
}
|
}
|
||||||
@@ -517,12 +521,16 @@ export class GameRenderer {
|
|||||||
|
|
||||||
const counters = layer.getPerfCounters?.();
|
const counters = layer.getPerfCounters?.();
|
||||||
if (counters && Object.keys(counters).length > 0) {
|
if (counters && Object.keys(counters).length > 0) {
|
||||||
|
if (layer instanceof UnitLayer) {
|
||||||
|
unitLayerCounters = counters;
|
||||||
|
}
|
||||||
const label = layer.constructor?.name ?? "UnknownLayer";
|
const label = layer.constructor?.name ?? "UnknownLayer";
|
||||||
layerCounters[label] = counters;
|
layerCounters[label] = counters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.performanceOverlay.updateLayerCounters(layerCounters);
|
this.performanceOverlay.updateLayerCounters(layerCounters);
|
||||||
|
this.performanceOverlay.updateUnitLayerCounters(unitLayerCounters);
|
||||||
|
|
||||||
if (shouldProfileTick) {
|
if (shouldProfileTick) {
|
||||||
this.performanceOverlay.updateTickLayerMetrics(tickLayerDurations);
|
this.performanceOverlay.updateTickLayerMetrics(tickLayerDurations);
|
||||||
|
|||||||
@@ -144,6 +144,9 @@ export class PerformanceOverlay extends LitElement implements Layer {
|
|||||||
@state()
|
@state()
|
||||||
private layerCounters: Record<string, Record<string, number>> = {};
|
private layerCounters: Record<string, Record<string, number>> = {};
|
||||||
|
|
||||||
|
@state()
|
||||||
|
private unitLayerCounters: Record<string, number> | null = null;
|
||||||
|
|
||||||
// Smoothed per-layer render-per-tick timings (EMA over recent ticks)
|
// Smoothed per-layer render-per-tick timings (EMA over recent ticks)
|
||||||
private renderPerTickLayerStats: Map<
|
private renderPerTickLayerStats: Map<
|
||||||
string,
|
string,
|
||||||
@@ -642,6 +645,7 @@ export class PerformanceOverlay extends LitElement implements Layer {
|
|||||||
this.renderLastTickLayerTotalMs = 0;
|
this.renderLastTickLayerTotalMs = 0;
|
||||||
this.renderLastTickLayerDurations = {};
|
this.renderLastTickLayerDurations = {};
|
||||||
this.layerCounters = {};
|
this.layerCounters = {};
|
||||||
|
this.unitLayerCounters = null;
|
||||||
this.renderPerTickLayerStats.clear();
|
this.renderPerTickLayerStats.clear();
|
||||||
this.renderLayersExpanded = false;
|
this.renderLayersExpanded = false;
|
||||||
this.tickLayersExpanded = false;
|
this.tickLayersExpanded = false;
|
||||||
@@ -841,6 +845,11 @@ export class PerformanceOverlay extends LitElement implements Layer {
|
|||||||
this.layerCounters = counters;
|
this.layerCounters = counters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateUnitLayerCounters(counters: Record<string, number> | null) {
|
||||||
|
if (!this.isVisible) return;
|
||||||
|
this.unitLayerCounters = counters;
|
||||||
|
}
|
||||||
|
|
||||||
updateTickMetrics(tickExecutionDuration?: number, tickDelay?: number) {
|
updateTickMetrics(tickExecutionDuration?: number, tickDelay?: number) {
|
||||||
if (!this.isVisible) return;
|
if (!this.isVisible) return;
|
||||||
|
|
||||||
@@ -957,6 +966,9 @@ export class PerformanceOverlay extends LitElement implements Layer {
|
|||||||
layers: this.layerBreakdown.map((layer) => ({ ...layer })),
|
layers: this.layerBreakdown.map((layer) => ({ ...layer })),
|
||||||
tickLayers: this.tickLayerBreakdown.map((layer) => ({ ...layer })),
|
tickLayers: this.tickLayerBreakdown.map((layer) => ({ ...layer })),
|
||||||
layerCounters: { ...this.layerCounters },
|
layerCounters: { ...this.layerCounters },
|
||||||
|
unitLayerCounters: this.unitLayerCounters
|
||||||
|
? { ...this.unitLayerCounters }
|
||||||
|
: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1032,7 +1044,7 @@ export class PerformanceOverlay extends LitElement implements Layer {
|
|||||||
|
|
||||||
const renderLayersToShow = this.layerBreakdown.slice(0, 10);
|
const renderLayersToShow = this.layerBreakdown.slice(0, 10);
|
||||||
const tickLayersToShow = this.tickLayerBreakdown.slice(0, 10);
|
const tickLayersToShow = this.tickLayerBreakdown.slice(0, 10);
|
||||||
const unitLayerCounters = this.layerCounters.UnitLayer ?? null;
|
const unitLayerCounters = this.unitLayerCounters;
|
||||||
|
|
||||||
const maxLayerAvg =
|
const maxLayerAvg =
|
||||||
renderLayersToShow.length > 0
|
renderLayersToShow.length > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user