title self explanatory
Everything is correct, except the part where it says that .PostSimulation runs before .Heartbeat, when the opposite is true:
In microprofiler, it appears that .PostSimulation runs after .Heartbeat:
The code to reproduce this: (localscript in StarterPlayer)
local RunService = game:GetService("RunService")
local function logevent(eventName)
debug.profilebegin(eventName)
for i = 1, 10000 do local a = Random.new():NextUnitVector() * math.random(100) end -- junk work to lengthen the frame
debug.profileend()
end
-- it doesnt matter in which order the events below are connected to a function
RunService.PreRender:Connect(function()
logevent("PreRenderEvent")
end)
RunService.RenderStepped:Connect(function()
logevent("RenderSteppedEvent")
end)
RunService.Stepped:Connect(function()
logevent("SteppedEvent")
end)
RunService.PreAnimation:Connect(function()
logevent("PreAnimationEvent")
end)
RunService.PreSimulation:Connect(function()
logevent("PreSimulationEvent")
end)
RunService.PostSimulation:Connect(function()
logevent("PostSimulationEvent")
end)
RunService.Heartbeat:Connect(function()
logevent("HeartbeatEvent")
end)
The correct ordering of the events according to the microprofiler, are:
- RenderStepped
- PreRender
- PreAnimation
- Stepped
- PreSimulation
- Heartbeat
- PostSimulation
Repro file: runservice ordering doc issue repro.rbxl (55.1 KB)
Page URL: https://create.roblox.com/docs/studio/microprofiler/task-scheduler#scheduler-priority