|
GeneralStonewall Magician
Joined: 02 Feb 2004 Posts: 364 Location: USA
|
Posted: Sat Oct 23, 2010 5:39 am
[3.31] #Update, windows 7, cpu usage. |
I have an alarm that uses #update on a single button every 0.1 second. Obviously, this is very fast, but I use it to update a button which displays the time left on an alarm, so precision is important. The issue is, this single alarm updating this single button is causing cmud to spike to 20% cpu usage while everything else is idle. This only became an issue after updating to windows 7, so while I realize it's likely a OS issue, I'm hoping it's fixable on cmud's side.
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sat Oct 23, 2010 3:39 pm |
What kind of variable? If it's a simple integer, then #UPDATE isn't even needed (and probably is causing your button refreshing to double up, hence the %20 spike).
If it's a datarecord, then your button is being refreshed every time any key in the variable is being changed--regardless of whether the button uses those keys or not.
Also, isn't the interval for alarms still kept to a minimum of .501 seconds? |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
GeneralStonewall Magician
Joined: 02 Feb 2004 Posts: 364 Location: USA
|
Posted: Sat Oct 23, 2010 11:09 pm |
There isn't a variable, it's just a display of %alarm( alarm_id ). Thus it doesn't auto-update.
Alarms definitely work at below .5 seconds. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Oct 25, 2010 5:11 pm |
That is a bad idea. The #UPDATE command causes Windows to repaint/refresh the screen. This will use a lot of CPU and cause a lot of lag, especially because Win7 and Vista have slower screen update routines (because of the "Window Composition" features, which you might try turning off unless you are in love with the Win7 fancy graphics).
There isn't any minimum for alarm times, so you are correct on that. Not sure what other solution to suggest. If you really need that sort of update precision then it's just going to take a lot of processing time.
You might try changing your 0.1 second alarm to just update a regular variable, like:
alarmVar = %alarm(alarm_id)
and then put @alarmVar into the button capture to allow CMUD to do auto updating and see if it makes any difference. |
|
|
|
GeneralStonewall Magician
Joined: 02 Feb 2004 Posts: 364 Location: USA
|
Posted: Mon Oct 25, 2010 5:30 pm |
Nope, afraid the variable solution by itself didn't help with the cpu usage. Though, what it does allow me to do is keep the alarm at the same time, but truncate the decimal places, which means it'll only auto-update every second, and still be accurate.
Thanks! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Oct 25, 2010 5:49 pm |
Yeah, since the CMUD auto-update was going to take the same time as the manual update, I didn't really expect it to change your CPU usage. But glad it helps make things more flexible.
|
|
|
|
|
|