Performance and memory
performanceDetect performance issues by reading engine counters, profiling script CPU usage, and analyzing scene memory and unparented instances.
Instructions
Reads the engine's own counters, and can run the script profiler.
snapshot returns what the Developer Console shows: frame, physics and render times in milliseconds, instance and part counts, draw calls, network rates, and memory broken down by category. Use it to answer 'why is this place heavy' with numbers instead of guesses.
profile runs Studio's script profiler — the Script Performance window — for seconds and reports which scripts consumed CPU. It blocks for that long, so keep it short. It only sees code that actually runs, so start a playtest first; profiling an idle edit session returns nothing.
coverage reports which lines of which scripts actually executed — dead code, untested branches, whether a fix was even reached. Pass enable first, then play, then read the coverage back FROM THE PLAYTEST session, not the editor: instrumenting is per data model, and the playtest is a different one. enable is remembered for the place and re-applied by each new session as it loads. Pass an empty enable array to stop.
What it can and cannot see: instrumentation is fixed when a script is first compiled, so it measures modules required after that point — where most game logic lives — but never a script that starts with the place, which the data model compiles before any plugin exists. Those report 0 lines and are named as unmeasurable rather than counted as dead code.
scene breaks the place down by what it is actually made of: instances by category, triangles and draw calls, and the assets holding script, animation and audio memory — each named, so "2.4GB of memory" becomes "this animation is 138KB and these are the Animators using it". It also reports UNPARENTED INSTANCES, which is the closest thing here to a leak detector: objects still alive with nothing holding them in the tree, invisible to find and to tree because they are in neither.
Frame and network figures are only meaningful while something is running. Instance counts and memory are useful in edit mode too.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op | No | 'snapshot' reads counters now; 'profile' samples running scripts; 'coverage' reports which lines have executed; 'scene' breaks the place down by what it is made of. | snapshot |
| enable | No | coverage only: scripts to start measuring. Remembered for this place and switched on by every session that loads afterwards, so a playtest instruments them before its scripts run. An empty array stops instrumenting. | |
| seconds | No | profile only: how long to sample. The call blocks for this long. | |
| section | No | scene only: return just one section instead of all six. | |
| studioId | No | Target Studio; omit for the active one. | |
| frequency | No | profile only: samples per second. Higher is more precise and costlier. | |
| includePlugins | No | profile only: include Studio plugins in the results. Off by default — an idle Studio is mostly plugin activity, which buries the place's own scripts. |