Roblox UtilitiesDevlHub Roblox Documentation

Class

Stats

NotCreatableService
Inherits
Instance › Object
Memory category
Instances

Performance metrics for a game.

Stats is a service that provides real-time performance information about the current running game instance. Its primary purpose is to provide an end point to measure where resources are being consumed, as well as how much memory is being consumed overall.

The service also stores a tree of StatsItem objects which can have their values read by plugins.

Properties 24#

ContactsCountintA measurement of how many parts are currently in contact with one another.ReadSafeReadOnlyNotReplicated
DataReceiveKbpsfloatIn a networked game, this describes roughly how many kilobytes of data are being received by the current instance, per second.ReadSafeReadOnlyNotReplicated
DataSendKbpsfloatIn a networked game, this describes roughly how many kilobytes of data are being sent by the current instance, per second.ReadSafeReadOnlyNotReplicated
FrameTimefloatA measurement of how long it takes for the engine to process all tasks required to render a frame.ReadSafeReadOnlyNotReplicated
HeartbeatTimefloatA measurement of the total amount of time it takes for the server to update its task scheduler jobs in seconds.ReadSafeReadOnlyNotReplicated
HeartbeatTimeMsfloatA measurement of the total amount of time it takes long it takes for Roblox to update all of its task scheduler jobs, in milliseconds.ReadSafeDeprecatedReadOnlyNotReplicated
InstanceCountintA measurement of how many Instance are currently in memory.ReadSafeReadOnlyNotReplicated
MemoryTrackingEnabledbooleanAn indication of whether memory tracking is enabled. This is guaranteed to be unchanged until the next time the Client is started.ReadSafeReadOnlyNotReplicated
MovingPrimitivesCountintA measurement of how many physically simulated components are currently moving in the game world.ReadSafeReadOnlyNotReplicated
PhysicsReceiveKbpsfloatIn a networked game, this describes roughly how many kilobytes of physics data are being received by the current instance, per second.ReadSafeReadOnlyNotReplicated
PhysicsSendKbpsfloatIn a networked game, this describes roughly how many kilobytes of physics data are being sent by the current instance, per second.ReadSafeReadOnlyNotReplicated
PhysicsStepTimefloatA measurement of how long it takes for the physics engine to update its current state.ReadSafeReadOnlyNotReplicated
PhysicsStepTimeMsfloatA measurement of how long it takes for the physics engine to update its current state, in milliseconds. If this value is high, then it means the game instance is under stress from the physics simulations taking place.ReadSafeDeprecatedReadOnlyNotReplicated
PrimitivesCountintA measurement of how many physically simulated components currently exist in the game world.ReadSafeReadOnlyNotReplicated
RenderCPUFrameTimefloatA measurement of how long it takes for the CPU to process all of its rendering tasks for a frame.ReadSafeReadOnlyNotReplicated
RenderGPUFrameTimefloatA measurement of how long it takes for the GPU to process all of its tasks required to render a frame.ReadSafeReadOnlyNotReplicated
SceneDrawcallCountintA measurement of the number of draw calls made by the game's current scene.ReadSafeReadOnlyNotReplicated
SceneTriangleCountintA measurement of the number of triangles rendered by the game's current scene.ReadSafeReadOnlyNotReplicated
ShadowsDrawcallCountintA measurement of the number of draw calls being made for shadows by the game's current scene.ReadSafeReadOnlyNotReplicated
ShadowsTriangleCountintA measurement of the number of triangles rendered as shadows in the game's current scene.ReadSafeReadOnlyNotReplicated
UI2DDrawcallCountintA measurement of the number of 2D draw calls made for UI elements in the game's current scene.ReadSafeReadOnlyNotReplicated
UI2DTriangleCountintA measurement of the number of triangles that are being rendered for 2D UI elements in the game's current scene.ReadSafeReadOnlyNotReplicated
UI3DDrawcallCountintA measurement of the number of 3D draw calls made for UI elements in the game's current scene.ReadSafeReadOnlyNotReplicated
UI3DTriangleCountintA measurement of the number of triangles being rendered for 3D UI elements in the game's current scene.ReadSafeReadOnlyNotReplicated

ContactsCount: int#

ReadOnlyNotReplicatedReadSafe

This property describes how many parts are currently in contact with each other, such that one of the two parts are being physically simulated, and thus can be recognized by the BasePart:GetTouchingParts() method.

DataReceiveKbps: float#

ReadOnlyNotReplicatedReadSafe

In a networked game, this property describes roughly how many kilobytes of data are being received by the current instance, per second. If from the server's perspective, this represents the total amount of data being received from the clients connected to the server. If from a client's perspective, this represents the total amount of data being received from the server.

DataSendKbps: float#

ReadOnlyNotReplicatedReadSafe

In a networked game, this property describes roughly how many kilobytes of data are being sent by the current instance, per second. If from the server's perspective, this represents the total amount of data being sent to the clients connected to the server. If from a client's perspective, this represents the total amount of data being sent to the server.

FrameTime: float#

ReadOnlyNotReplicatedReadSafe

This property is only available in client scripts and is a measurement of how long it took to render the most-recent frame in seconds. Divide 1 by this value to calculate an FPS value for the frame time. High frame times are indicative of performance problems on the device. Consider using the MicroProfiler to troubleshoot.

HeartbeatTime: float#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the total amount of time it takes for the server to update its task scheduler jobs in seconds. If this value is high, examine server compute.

HeartbeatTimeMs: float#

ReadOnlyNotReplicatedDeprecatedReadSafeDeprecated

Deprecated. Use Stats.HeartbeatTime instead.

The HeartbeatTimeMs property is a measurement of the total amount of time it takes long it takes for Roblox to update all of its task scheduler jobs, in milliseconds. If this value is high, then it means one of the tasks are hogging up a lot of resources.

InstanceCount: int#

ReadOnlyNotReplicatedReadSafe

InstanceCount is a read-only measurement of how many Instance are currently in memory. This includes the DataModel, its descendants, as well as any object created with Instance.new() which is still present in memory.

MemoryTrackingEnabled: boolean#

ReadOnlyNotReplicatedReadSafe

If MemoryTrackingEnabled returns false, any API that returns category-based memory usage such as Stats:GetMemoryUsageMbForTag() or Stats:GetMemoryUsageMbAllCategories() will return 0 and emit a warning. Therefore, usage of category-based memory usage API should be conditional on MemoryTrackingEnabled returning true. The value of MemoryTrackingEnabled will not change from one experience to the next; it will only potentially change after restarting the Roblox client application.

MovingPrimitivesCount: int#

ReadOnlyNotReplicatedReadSafe

A measurement of how many physically simulated components are currently moving in the game world.

PhysicsReceiveKbps: float#

ReadOnlyNotReplicatedReadSafe

PhysicsReceiveKbps is a measurement of roughly how many kilobytes of physics data are being received by the current instance, per second.If from the server's perspective, this represents the total amount of physics data being received from the clients connected to the server.If from a client's perspective, this represents the total amount of physics data being received from the server.

PhysicsSendKbps: float#

ReadOnlyNotReplicatedReadSafe

PhysicsSendKbps describes roughly how many kilobytes of physics data are being sent by the current instance, per second. If from the server's perspective, this represents the total amount of physics data being sent to the clients connected to the server. If from a client's perspective, this represents the total amount of physics data being sent to the server.

PhysicsStepTime: float#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of how long it takes for the physics engine to update its current state. If this value is high, it means the game instance is under stress from the physics simulations taking place.

PhysicsStepTimeMs: float#

ReadOnlyNotReplicatedDeprecatedReadSafeDeprecated

Deprecated. Use Stats.PhysicsStepTime instead.

A measurement of how long it takes for the physics engine to update its current state, in milliseconds. If this value is high, then it means the game instance is under stress from the physics simulations taking place.

PrimitivesCount: int#

ReadOnlyNotReplicatedReadSafe

A measurement of how many physically simulated components currently exist in the game world.

RenderCPUFrameTime: float#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of how long it takes for the CPU to process all of its rendering tasks for a frame.

RenderGPUFrameTime: float#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of how long it takes for the GPU to process all of its tasks required to render a frame.

SceneDrawcallCount: int#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the number of draw calls made by the game's current scene. A draw call is a single rendering operation, such as drawing a mesh. A high draw call count could mean a scene is too complex or unoptimized, which can lead to performance issues.

SceneTriangleCount: int#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the number of triangles rendered by the game's current scene. A count of triangles rendered is useful when trying to estimate the complexity and performance of a scene.

ShadowsDrawcallCount: int#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the number of draw calls being made for shadows by the game's current scene. A high count means more shadows are being created by the amount of rendered objects in a scene.

ShadowsTriangleCount: int#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the number of triangles rendered as shadows in the game's current scene. A high count means there are a lot of triangles used to cast shadows, which can hinder performance.

UI2DDrawcallCount: int#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the number of 2D draw calls made for UI elements in the game's current scene. A high count can mean there are a lot of 2D UI elements being used.

UI2DTriangleCount: int#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the number of triangles that are being rendered for 2D UI elements in the game's current scene. A high count can mean there are many or complex 2D UI elements used, which can contribute to performance loss in regards to rendering.

UI3DDrawcallCount: int#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the number of 3D draw calls made for UI elements in the game's current scene. A high count could indicate a high amount of 3D objects being used within UI, potentially hurting performance; however, it is very unlikely you would see a significant count since UI elements are typically 2D.

UI3DTriangleCount: int#

ReadOnlyNotReplicatedReadSafe

This property is a measurement of the number of triangles being rendered for 3D UI elements in the game's current scene; however, it is very unlikely you would see a significant count since UI elements are typically 2D.

Methods 7#

GetHarmonyQualityLevelInternal-only. Returns the engine's current dynamic-quality level as a score normalized from 0 to 100.
GetMemoryCategoryNamesInternal-only. Returns an array of the names of every developer memory category the engine tracks.
GetMemoryUsageMbAllCategoriesReturns the number of megabytes that are being consumed by all available categories, or an empty array if MemoryTrackingEnabled is false.
GetMemoryUsageMbForTagReturns the number of megabytes that are being consumed in the specified DeveloperMemoryTag category, or 0 if MemoryTrackingEnabled is false.
GetTotalMemoryUsageMbReturns the total amount of memory being consumed by the current game session, in megabytes.
ResetHarmonyMemoryTargetInternal-only. Restores the performance-control system's memory budget to the values in effect before Stats:SetHarmonyMemoryTarget() was called.
SetHarmonyMemoryTargetInternal-only. Overrides the performance-control system's memory budget with a target value, in megabytes, for testing.

GetHarmonyQualityLevel(): int#

Requires the InternalTest security capability; not callable from ordinary scripts. Returns the current quality level selected by the engine's dynamic performance-control system, expressed as a score normalized between 0 (the lowest-quality configuration) and 100 (the highest). The score reflects how the system is currently balancing visual quality against resource usage such as memory and frame time.

Returns
  • int — The current dynamic-quality level, normalized from 0 (lowest quality) to 100 (highest quality).

GetMemoryCategoryNames(): Array#

Requires the InternalTest security capability; not callable from ordinary scripts. Returns an array of strings containing the name of every memory category the engine tracks, in category-index order. The entries correspond one-to-one with the measurements returned by Stats:GetMemoryUsageMbAllCategories(), so the two arrays can be read together to label each per-category memory value.

Returns

GetMemoryUsageMbAllCategories(): Array#

Returns the number of megabytes that are being consumed by all available categories. If MemoryTrackingEnabled is false, calling GetMemoryUsageMbAllCategories() will return an empty array and emit a warning to the console.

Returns

GetMemoryUsageMbForTag(tag: DeveloperMemoryTag): float#

Returns the number of megabytes that are being consumed in the specified DeveloperMemoryTag category. If MemoryTrackingEnabled is false, calling GetMemoryUsageMbForTag() will return 0 and emit a warning to the console.

NameTypeDefaultDescription
tagDeveloperMemoryTagThe DeveloperMemoryTag memory category to measure.
Returns

GetTotalMemoryUsageMb(): float#

Returns the total amount of memory being consumed by the current game session, in megabytes.

This method gets memory usage from the operating system, which may exclude memory that has been paged out to disk. As such, the return value tends to differ significantly from the sum of usage for all DeveloperMemoryTags. The return value should be very similar to memory usage for Roblox in the Windows Task Manager or macOS Activity Monitor.

Returns
  • float — The total memory, in megabytes, used by the current game session, as reported by the operating system.

ResetHarmonyMemoryTarget(): ()#

Requires the InternalTest security capability; not callable from ordinary scripts. Reverts the artificial memory budget applied by Stats:SetHarmonyMemoryTarget(), restoring the memory-override enable state and limit that were captured before the first call to SetHarmonyMemoryTarget(). After this call, the performance-control system resumes using the device's real available memory when making dynamic-quality decisions.

Returns
  • ()

SetHarmonyMemoryTarget(targetMB: int): ()#

Requires the InternalTest security capability; not callable from ordinary scripts. Forces the engine's dynamic performance-control system to operate against an artificial memory budget of targetMB megabytes instead of the device's real available memory, making it behave as though only that much memory is available. This lets you test how dynamic quality and memory reclamation respond under a chosen level of memory pressure. The first call records the pre-override settings so that a later call to Stats:ResetHarmonyMemoryTarget() can restore them.

NameTypeDefaultDescription
targetMBintThe memory budget to impose on the performance-control system, in megabytes.
Returns
  • ()

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed