Speed question: timers.

Posted by Alca on Thu 28 Jan 2010 10:45 PM — 3 posts, 14,381 views.

#0
I want to make a visual reminder of the time left before I regain balance/equilibrium/anything.

Now this is easily done using a timer, set to an interval to match the precision I want. Because I want a gradient to refill an empty bar (full bar meaning 'balance back'), I'll use a 0.1 second timer.

The question is: what would be faster/less restraining for my system? One timer for each bar, or one timer coupled with a BroadcastPlugin?

My reason for using broadcasts is so I can use different plugins for different bars.

I'd like to know if using BroadcastPlugin would eat up loads of CPU, or if it is minimal.

(I'm also toying with the idea of having one timer to serve as a 'heartbeat' for different plugins. Is this viable, considering speed and such?)
Australia Forum Administrator #1
I would go with BroadcastPlugin, rather than filling up MUSHclient's timer queue with lots of timers. A quick test shows:


tstart = GetInfo (232)  -- high performance timer

for i = 1, 1000000 do
  BroadcastPlugin (100, "some message") 
end -- for

tend = GetInfo (232)
print ("Time taken =", tend - tstart)


Results:


Time taken = 0.32689229305834


So basically you could do over 3,000,000 BroadcastPlugin in a second, so I doubt you will notice the overhead.
#2
Exactly what I needed! Thanks :)