mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Major performance improvements
This commit is contained in:
@@ -1,19 +1,33 @@
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
import { makeDiv, round3Digits } from "../../../core/utils";
|
||||
import { makeDiv, round3Digits, round2Digits } from "../../../core/utils";
|
||||
import { Math_round } from "../../../core/builtins";
|
||||
|
||||
export class HUDDebugInfo extends BaseHUDPart {
|
||||
createElements(parent) {
|
||||
this.element = makeDiv(parent, "ingame_HUD_DebugInfo", []);
|
||||
|
||||
this.tickRateElement = makeDiv(this.element, null, ["tickRate"], "Ticks /s: 120");
|
||||
this.fpsElement = makeDiv(this.element, null, ["fps"], "FPS: 60");
|
||||
this.tickDurationElement = makeDiv(this.element, null, ["tickDuration"], "Update time: 0.5ms");
|
||||
}
|
||||
|
||||
initialize() {}
|
||||
initialize() {
|
||||
this.lastTick = 0;
|
||||
}
|
||||
|
||||
update() {
|
||||
this.tickRateElement.innerText = "Tickrate: " + this.root.dynamicTickrate.currentTickRate;
|
||||
this.tickDurationElement.innerText =
|
||||
"Avg. Dur: " + round3Digits(this.root.dynamicTickrate.averageTickDuration) + "ms";
|
||||
const now = this.root.time.realtimeNow();
|
||||
if (now - this.lastTick > 0.25) {
|
||||
this.lastTick = now;
|
||||
this.tickRateElement.innerText = "Tickrate: " + this.root.dynamicTickrate.currentTickRate;
|
||||
this.fpsElement.innerText =
|
||||
"FPS: " +
|
||||
Math_round(this.root.dynamicTickrate.averageFps) +
|
||||
" (" +
|
||||
round2Digits(1000 / this.root.dynamicTickrate.averageFps) +
|
||||
" ms)";
|
||||
this.tickDurationElement.innerText =
|
||||
"Tick Dur: " + round3Digits(this.root.dynamicTickrate.averageTickDuration) + "ms";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user