http://www.byond.com/forum/?post=2055964
____________________________________________________________ ____
SS13 has always had the issue of lag and shit performance, it was usually playable, but the freezes and lagspikes eventually ended up being quite irritating. Since a few years we've had a new controller (basically process manager), and some nifty additions to the code that really helped on performance. I am here to show you the 'key', which you can apply anywhere in laggy for/while loops. It is:
(make sure to add it in a file that is above most, since otherwise it will not recognize it)
#define CHECK_TICK if(world.tick_usage > 80) sleep(world.tick_lag)
You can apply CHECK_TICK under your loops (Not movement though, since it does add a small delay) that should streamline your functions more and spread it over multiple ticks. Its been a very useful addition to SS13, and it may help you too. Just put it at the end (inside) your expensive loops that aren't reliant on ('immediate') performance. (like movement!)
Why 80 as a value? From what I've gathered the server also sends map updates at the end of you ticks, 80 seemed to be the perfect value to keeping performance in line with lag, but you can always give it a bump up to 85ish to see how that fares.
I do not take any credit, I'm just posting it here because I feel many games could do with some improved speeds, and this is the most simple approach to try and balance it out. Good, efficient coding is still key!
With this, you can also potentially reduce your tick_lag rate, providing you with a smoother looking game.
Enjoy!
But this is just for SS13 what has BYOND become, do we not make games anymore and focus on SS13?
P.s change the title, very misleading..