PerformanceService
Returns bounded runtime performance counters and timing samples.
Required setup
Section titled “Required setup”No additional capability token. This service is available through the runtime; individual feature results still depend on the selected host.
The host is the program running your Luau code: normally the SDK’s native runner. Its provider/adapter implements an optional service. You do not need to write one to use a service already supplied by the SDK. Capabilities explains the manifest and remaining platform limits.
Example
Section titled “Example”Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.
local Window = Instance.new("Window", { Title = "LUI example", Size = UDim2.fromOffset(560, 280),})local Status = Instance.new("TextLabel", { Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170), Size = UDim2.new(1, -32, 0, 72),})local Performance = app:GetService("PerformanceService")local Start = Performance:GetTime()task.delay(0.1, function() local Stats = Performance:GetStats() Status.Text = "Elapsed ms: " .. math.floor(Performance:GetTime() - Start) .. "; live Instances: " .. Stats.LiveInstancesend)Window.Visible = trueExpected result: Displays elapsed milliseconds and a runtime counter. The delay is scheduled work, not a precise real-time timer.
Methods
Section titled “Methods”GetStats
Section titled “GetStats”Returns a read-only snapshot of counters and collected timings. It does not measure physical display latency.
GetStats() -> PerformanceStatsGetTime
Section titled “GetTime”Returns steady-clock milliseconds. Subtract two readings for elapsed time; use os.time/os.date for calendar dates.
GetTime() -> numberFull type declaration — for type checking and deeper reference
The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.
export type PerformanceService = { read GetStats: (Self: PerformanceService) -> PerformanceStats, read GetTime: (Self: PerformanceService) -> number,}Availability and deeper reading
Section titled “Availability and deeper reading”See platform limits before relying on host-specific behavior. The framework design specification and reflection/type sources are deeper engineering references, not extra setup required to build an app.