[Pawn] Best practice with timers - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] Best practice with timers (/showthread.php?tid=1569) |
Best practice with timers - RhaegarX - 2021-01-21 Hello guys!? I would like to ask a question about the use of timers.? Suppose I have several systems that do checks from time to time, the best way would be to create a single timer that does all the checks or create multiple timers to check each thing?? Which way would be the most optimized and least burdensome on the server? Code 1: PHP Code: SetTimer("ExecuteAll", 1000, false); Code 2: PHP Code: SetTimer("Execute1", 1000, false); RE: Best practice with timers - Pinch - 2021-01-21 Just don't have more than 50.000 running timers at the same time and everything will be fine, it's case to case dependant so I can't really tell what's better RE: Best practice with timers - Freaksken - 2021-01-21 Y_Less made a post on this exact issue on the old forums (can't find it anymore in any archive). Consensus was that you should use more timers instead of a single timer that does everything. RE: Best practice with timers - Markski - 2021-01-22 depends on what the code does, If it's very complex code then it should be on it's own timer. If it's dumb stuff like checking the state of variables and -- or 'ng stuff every 1 second or whatever, then you can bundle all of that in a single func. Microoptimizations like having every single little thing on it's own timer only go so far before they have no effect and only make your code harder to look at |