How to check script performance ingame?

I have a game (Bloxy Golfing)that seems to be working fine and smooth, but on mobile as time passes the game keeps getting more CPU usage, and I think that might be a memory leak. It starts at 15-20 ms and when i finish the courses the ms goes up to 35-40 and sometime spikes to 50. I use a lot of loops, and I think they might not be stopping when I want them to, so that might be the issue. What I want to know is how to check script performance ingame, so I can check which script is running too much on my smartphone.
EDIT: and I tried running it on studio with a mobile device simulation, nothing happened there. Maybe it’s my phone, but it’s weird as it runs max level graphics while my pc only handles lvl 2 out of 10. Also other games i test on mobile doesn’t have this problem.

Check out a recent DevForum post on how to achieve this:

1 Like

When you use more loops you add more work going into the TaskScheduler and should try as much as possible to be more Event Driven Oriented with your programming. Check my tutorial linked above.

Also, device emulation for checking performance is unreliable and inaccurate, please test on your actual phone as explained in the tutorial thread.

1 Like

Yes, I know about the problem of loops. I try to keep most of them as events but some things really need to be loops here. For example, when a player strikes the golf ball, a real time camera is cframed constantly with lerp to track the ball using its speed as parameter, and it changes angles like when its close to the hole or when it has slowed down, which is something tweens arent capable of doing. I thought I made sure to stop these loops by unbinding them (they are bind to renderstep loops) when not needed but somehow on mobile something is happening that slows the game fps as time passes.

Here is how I decide to bind or unbind the loops:

  • event triggers a function:
  • Event function instantly unbinds everything from renderstep, without any checks;
  • Checks if a new renderstep function must be bound (ex: camera manipulation), if it does, then it binds the function.

So I don’t really know how this is getting fps loss issues. The loop function isn’t getting added repetitively, as it always stops the previous loop when starting a new one. I am starting to think it might even be something to do with my device because only on mobile it happens, but everyone I ask says that they dont notice any lag, and most of them play on tablets/smartphones.