Skip to content

FrameStats

Type

FrameStats reports how long each part of the engine took in the last frame, in seconds, and how much memory Luau uses, in bytes. Profiler.Frame returns it.

Example

-- Client script: warn when a frame takes longer than 1/30 second.
function Update(dt: number)
    local frame = Profiler.Frame()
    if frame and frame.Interval > 0.033 then
        local logic = math.round(frame.Sim * 1000)
        local drawing = math.round(frame.Render * 1000)
        warn(`slow frame: {logic} ms logic, {drawing} ms drawing`)
    end
end

Interval

Field
Interval: number

Interval is the time in seconds from the start of the previous frame to the start of this one, or 0 on the first frame.

Sim

Field
Sim: number

Sim is the time in seconds spent on game logic: scripts, physics, and networking.

Script

Field
Script: number

Script is the time in seconds spent running Luau scripts. Profiler.Scripts gives the time per script.

Physics

Field
Physics: number

Physics is the time in seconds spent on physics.

Network

Field
Network: number

Network is the time in seconds spent sending and receiving network messages.

Render

Field
Render: number

Render is the time in seconds the client took to prepare its last drawn frame. It is 0 on the server.

Heap

Field
Heap: number

Heap is the size of the Luau heap in bytes. If it keeps rising, scripts are keeping references to data they are done with.

HeapGrowth

Field
HeapGrowth: number

HeapGrowth is how fast the Luau heap grows, in bytes per second, smoothed over recent frames in which it grew.