Class ResourceStats
java.lang.Object
dev.engine.core.profiler.ResourceStats
Tracks native resource lifecycle statistics: live totals and per-frame operation counters.
Each resource type is identified by a string key (e.g. "buffer", "texture").
New resource types can be added at any time — the first call to any record* method
with an unknown key auto-registers it.
The tracker has two layers:
- Live totals — absolute count of currently alive resources, never reset. Thread-safe (atomic integers).
- Frame counters — per-frame create/destroy/use/update counts with a
current/last frame model. Call
newFrame()at the start of each frame to swap: current becomes last (readable by consumers), current resets to zero.
Operations tracked per frame:
- created — new resources allocated this frame
- destroyed — resources freed this frame (when deferred deletion actually runs)
- used — resources bound/referenced for reading (e.g. texture sampled, buffer bound)
- updated — resources written to (e.g. buffer upload, texture data update)
// Record operations during the frame:
resourceStats.recordCreate("buffer");
resourceStats.recordUpdate("buffer"); // wrote data into it
resourceStats.recordUse("texture"); // bound for sampling
// At frame start:
resourceStats.newFrame();
// Read completed previous frame:
int buffersCreated = resourceStats.lastFrameCreated("buffer");
int texturesUsed = resourceStats.lastFrameUsed("texture");
// Live totals are always current:
int liveBuffers = resourceStats.liveCount("buffer");
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcurrentFrameCreated(String resourceType) intcurrentFrameDestroyed(String resourceType) intcurrentFrameUpdated(String resourceType) intcurrentFrameUsed(String resourceType) intlastFrameCreated(String resourceType) intlastFrameDestroyed(String resourceType) intlastFrameUpdated(String resourceType) intlastFrameUsed(String resourceType) intReturns the current live count for the given resource type, or 0 if unknown.voidnewFrame()Swaps frame counters: current becomes last, current resets to zero.voidrecordCreate(String resourceType) Records a resource creation.voidrecordDestroy(String resourceType) Records a resource destruction.voidrecordUpdate(String resourceType) Records a resource being updated (written/uploaded) this frame.voidRecords a resource being used (bound/read) this frame.voidPre-registers a resource type.Returns an unmodifiable view of all tracked resource type names.toString()intintintintintReturns the sum of all live resources across all tracked types.
-
Constructor Details
-
ResourceStats
public ResourceStats()
-
-
Method Details
-
register
Pre-registers a resource type. Optional — types are auto-registered on first use. -
resourceTypes
-
recordCreate
Records a resource creation. Increments live total and current frame created counter. -
recordDestroy
Records a resource destruction. Decrements live total and increments current frame destroyed counter. -
recordUse
Records a resource being used (bound/read) this frame. -
recordUpdate
Records a resource being updated (written/uploaded) this frame. -
newFrame
public void newFrame()Swaps frame counters: current becomes last, current resets to zero. Call once at the start of each frame, before any record operations. -
liveCount
Returns the current live count for the given resource type, or 0 if unknown. -
totalLiveCount
public int totalLiveCount()Returns the sum of all live resources across all tracked types. -
lastFrameCreated
-
lastFrameDestroyed
-
lastFrameUsed
-
lastFrameUpdated
-
totalLastFrameCreated
public int totalLastFrameCreated() -
totalLastFrameDestroyed
public int totalLastFrameDestroyed() -
totalLastFrameUsed
public int totalLastFrameUsed() -
totalLastFrameUpdated
public int totalLastFrameUpdated() -
currentFrameCreated
-
currentFrameDestroyed
-
currentFrameUsed
-
currentFrameUpdated
-
toString
-