1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Further performance improvements

This commit is contained in:
tobspr
2020-08-15 22:44:15 +02:00
parent b2880700e8
commit b7efda9bf6
5 changed files with 49 additions and 12 deletions

View File

@@ -13,7 +13,7 @@ import { round1Digit } from "./utils";
const logger = createLogger("buffers");
const bufferGcDurationSeconds = 10;
const bufferGcDurationSeconds = 5;
export class BufferMaintainer {
/**
@@ -31,6 +31,29 @@ export class BufferMaintainer {
this.root.signals.gameFrameStarted.add(this.update, this);
}
/**
* Returns the buffer stats
*/
getStats() {
let stats = {
rootKeys: 0,
subKeys: 0,
vramBytes: 0,
};
this.cache.forEach((subCache, key) => {
++stats.rootKeys;
subCache.forEach((cacheEntry, subKey) => {
++stats.subKeys;
const canvas = cacheEntry.canvas;
stats.vramBytes += canvas.width * canvas.height * 4;
});
});
return stats;
}
/**
* Goes to the next buffer iteration, clearing all buffers which were not used
* for a few iterations