Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Speed question: timers.

Speed question: timers.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Alca   (20 posts)  Bio
Date Thu 28 Jan 2010 10:45 PM (UTC)
Message
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?)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 28 Jan 2010 10:56 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Alca   (20 posts)  Bio
Date Reply #2 on Sun 31 Jan 2010 06:14 PM (UTC)
Message
Exactly what I needed! Thanks :)
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,052 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.