ScriptProfilerService provides a scripting interface to Roblox's Luau script
profiler, which periodically samples running Luau threads to attribute CPU
time to the functions that consume it.
Profiling is controlled independently for the server and for individual
clients: ServerStart() and
ServerStop() govern server-side
scripts, while ClientStart() and
ClientStop() govern a given
player's client. Calling
ServerRequestData() or
ClientRequestData() collects
a snapshot of the profiling results, which is delivered asynchronously through
the OnNewData event as a JSON string.
That string can be turned into a structured Luau table with
DeserializeJSON().
This service powers the Script Profiler in the in-experience Developer
Console.
Requests a snapshot of the profiling data collected for the given player's
client. The data is not returned directly; instead it is delivered
asynchronously through the
OnNewData event as a JSON string.
When called on the server this replicates a data request to the target
client, and when called on the client it gathers the local player's
profiling data directly. On a client the player argument must be the
local player.
Begins profiling the Luau scripts running on the given player's client.
The profiler periodically samples running Luau threads at frequency
samples per second; if frequency is omitted it defaults to 1000, and a
value outside the range [1, 10000] raises an error.
When called on the server this replicates a request to the target client
to start profiling, and when called on the client it starts sampling the
local player's scripts directly. On a client the player argument must be
the local player.
Stops profiling the Luau scripts running on the given player's client.
When called on the server this replicates a request to the target client
to stop profiling, and when called on the client it stops sampling the
local player's scripts directly. On a client the player argument must be
the local player.
Converts the raw JSON produced by the profiler into a Luau table so the
results can be inspected programmatically rather than parsed by hand. The
returned table mirrors the profiling session, exposing entries such as its
version, session start and end times, categories, call nodes, and function
metadata.
An empty or non-object input yields no data.
This function has a custom internal state. It may behave in a non-standard way.
Fires when a new profiling snapshot becomes available, in response to
ClientRequestData() or
ServerRequestData(). The
data is delivered as a JSON string in jsonString; pass it to
DeserializeJSON() to
obtain a structured table. player identifies the client the data came
from, or is nil when the data was collected on the server.
Requests a snapshot of the profiling data collected on the server. The
data is not returned directly; instead it is delivered asynchronously
through the OnNewData event as a
JSON string, with no associated player.
Begins profiling the Luau scripts running on the server. The profiler
periodically samples running Luau threads at frequency samples per
second; if frequency is omitted it defaults to 1000, and a value
outside the range [1, 10000] raises an error.