Lag related to timers.
#1

Hello fellow scripters,

I am working on a timer script and I have a few questions about timers. On the SA:MP wiki, they tell you that timers would cause increase youre amount of cpu/memory usage if youґd use many of them.(lag)

1. Does the repeat time of a timer have influence on the amount of lag caused by timers? For instance, you have a timer wich repeats something every second, and a timer that repeats something every 10 ms. Does the 10 ms use more cpu/memory space?

2. Is the amount of functions you call in `public timername()` related to causing more or less lag? Would calling more functions there influence the cpu/memory usage?

3.Scripting question: Is it possible to create youre own custom animations with PAWN?

Thanks alot in advance.

Cheers,
Cpt.Falcon
Reply
#2

I am pretty sure that timers only lag when you have very many going on at the SAME time
Reply
#3

to estimate the CPU usage you can use this formula:
CPU usage = (1000 ms / delay in ms) * scriptsize
1 second equals 1000 milliseconds. if you got a timer running on a very low delay, like 10 ms, it will get launched 100 times per second (1000/10 = 100). multiply that amount with the scipt sontent. its vital to avoid big loops and deep mathematical calculations. using a timer of 1000 instead 100 ms, will use 1/10 of the CPU time then. for empty timers, the lower one will use some CPU time indeed, coz it gets "triggered" more often. avoid per player timers running forever, they can cause trouble if some other vital timers "needs" to be called at a time where a "per player" timer is running. doing a loop for all players in one seperate timer, is the best way to take care for all players...
Reply
#4

Try to use not so many timers. Maybe some globaltimers.

- Lj
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)