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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user