mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-26 09:14:36 +00:00
Add performance metrics for worker and render ticks
- Introduced new metrics in ClientGameRunner to track worker simulation ticks and render tick calls per second. - Updated TickMetricsEvent to include these new metrics. - Enhanced PerformanceOverlay to display worker and render ticks per second, improving performance monitoring capabilities. - Adjusted minimum FPS in GameRenderer
This commit is contained in:
@@ -233,6 +233,9 @@ export class ClientGameRunner {
|
||||
private backlogTurns: number = 0;
|
||||
private backlogGrowing: boolean = false;
|
||||
private lastRenderedTick: number = 0;
|
||||
private workerTicksSinceSample: number = 0;
|
||||
private renderTicksSinceSample: number = 0;
|
||||
private metricsSampleStart: number = 0;
|
||||
|
||||
private pendingUpdates: GameUpdateViewData[] = [];
|
||||
private pendingStart = 0;
|
||||
@@ -495,6 +498,7 @@ export class ClientGameRunner {
|
||||
while (this.pendingStart < this.pendingUpdates.length) {
|
||||
const gu = this.pendingUpdates[this.pendingStart++];
|
||||
processedCount++;
|
||||
this.workerTicksSinceSample++;
|
||||
batch.push(gu);
|
||||
|
||||
this.transport.turnComplete();
|
||||
@@ -545,6 +549,24 @@ export class ClientGameRunner {
|
||||
: lastTick - this.lastRenderedTick;
|
||||
this.lastRenderedTick = lastTick;
|
||||
|
||||
this.renderTicksSinceSample++;
|
||||
|
||||
let workerTicksPerSecond: number | undefined;
|
||||
let renderTicksPerSecond: number | undefined;
|
||||
const now = performance.now();
|
||||
if (this.metricsSampleStart === 0) {
|
||||
this.metricsSampleStart = now;
|
||||
} else {
|
||||
const elapsedSeconds = (now - this.metricsSampleStart) / 1000;
|
||||
if (elapsedSeconds > 0) {
|
||||
workerTicksPerSecond = this.workerTicksSinceSample / elapsedSeconds;
|
||||
renderTicksPerSecond = this.renderTicksSinceSample / elapsedSeconds;
|
||||
}
|
||||
this.metricsSampleStart = now;
|
||||
this.workerTicksSinceSample = 0;
|
||||
this.renderTicksSinceSample = 0;
|
||||
}
|
||||
|
||||
this.renderer.tick();
|
||||
this.eventBus.emit(
|
||||
new TickMetricsEvent(
|
||||
@@ -552,6 +574,8 @@ export class ClientGameRunner {
|
||||
this.currentTickDelay,
|
||||
this.backlogTurns,
|
||||
ticksPerRender,
|
||||
workerTicksPerSecond,
|
||||
renderTicksPerSecond,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user