(This is about lag in terms of framedrops, scripts taking long to finish, glitchyness, general stuff that happens if you use too much calculation time, sorry if I didn't word the title correctly)
I have a game that uses a lot of intensive scripts, I can see script performance peak at some points. The script that uses the most calculation time is one that loads a graph in the beginning of the game and peaks at 55%. That's just loading in the beginning, while players have to wait anyway, so it's nothing too bad if that causes framedrops etc, it'll be over soon enough anyway. The problem is when the game actually starts, there are potentially hundreds of scripts running then to control my zombies(I made them a bit more intelligent than the standard zombie, but that took some sacrifices in performance).
Right now I see that the performance for 100 zombies stays at around 3%, but can peak to 5% if a lot of them need to do the heavy part of the calculations at the same time. (Also, if I have 100 of the same scripts running and it says 3%, is that for all 100 combined or for each one separatly? I know 300% is kinda impossible, but you never know lol)
I have one suggestion myself that could measure it, but I don't know how useful it might be. I read on the roblox blog that a wait() may change in length depending on how much calculation power you have. So knowing that I put up this simple bit of code:
while true do
local waittime = wait()
print(waittime)
end
Using this bit of code during that loading time that took 55% performance I did notice that it could go up to 0.09 while it's supposed to be 0.3333333. However, is this a general thing I can use? Can I just assume that the bigger that number is, the greater the lag, the more I should lower refreshrate in my calculations? And are there better alternatives?

1 comment
Yeah I know, but it's not just for having the information, I'd like to make something that can measure the lag and adapts the scripts accordingly. For exemple, if the script notices a lot of lag, it would increase waittimes for certain calculations, getting a bit of the load off of the server.