Hello. I just realized that a ton of my GUI and camera code contains several BindToRenderStep calls that fire with user input, and many contain ruthless calculations such as distance, circle, and CFrame formulas. Shockingly enough, I don’t notice a huge performance impact (for my PC at least), but I would like to perhaps rethink the way I tween GUIs and camera movement.
GUI tweening binds are immediately disconnected the moment the player no longer sees that specific portion of the GUI, so that’s a plus I guess. I was wondering if combining all binds of the same render priority to a single bind would improve performance:
Also, does BindToRenderStep effectively establish an event connection? Many people say that the connection of events is pretty intensive, so I might want to avoid calling it excessively if it does.
@anime_bb heey mate so how to do it is u need to join the code together to put it together of what you want if u get what I mean but try that and see how it goes!
It works akin to RunService’s event loops (Stepped, RenderStepped, Heartbeat), in that the result is a callback function which executes every frame, the main differences are that BindToRenderStep allows you to bind to a particular priority whereas the aforementioned event loops do not and that event loops are disconnected through the ‘:Disconnect()’ method of RBXScriptConnection objects whereas a function bound to each render step is unbound via the UnbindFromRenderStep method.
So if BindToRenderStep effectively does the same thing as a connection to RenderStepped, and less connections are preferable to minimize performance impact, would it be optimal to limit the amount of binds I perform?
If there‘a no performance impact, don’t waste your time optimizing!
Optimize the things that matter, not the ones that dont.
I doubt it, and if so, a minuscule amount.
Maybe, but probably not exactly. Normal events don’t have a sorted priority ordering, so I would bet functions stored by BindToRenderStep use a different mechanism than that by e.g. RenderStepped:Connect.
Seeing as most of Roblox’s systems heavily use the event system, I doubt this is true. Evidenced by the fact that you don’t see performance impacts.
tl;dr: maybe technically combining is faster, but I doubt it’s any sort of bottleneck. Measure it and find out!