Author Topic: Background process load  (Read 219 times)

GreyArea

  • Newbie
  • *
  • Posts: 34
Background process load
« on: March 20, 2017, 01:24:05 pm »
Just had a thought about my "Confirmation" Routine in my "Play Elite" launcher posted in "profiles"...it means the "Play ELite" command is still running in the background, as is the "Confirmation" routine if the user doesn't actually give an answer (It's on my list of things to do to add an "are you still there?" reminder every minute or so).

How much load does this put on the system?

Pfeil

  • Hero Member
  • *****
  • Posts: 805
  • RTFM
Re: Background process load
« Reply #1 on: March 20, 2017, 02:47:50 pm »
How much load does this put on the system?
It's relative to the performance of your hardware. For one or two commands it shouldn't be a huge issue, however best practice is to terminate commands you no longer need.

I did a quick test on my machine: With 70 infinitely looping commands running in the background, VoiceAttack started showing CPU usage spikes of 5%.


If you want to build a timeout into your command, so it self-terminates, you can do the following:
Code: [Select]
Set decimal [~CommandStarted] value to the converted value of {DATETICKS}
Start Loop While : [{EXP:1=1}] Equals '1'
    Begin Text Compare : [{EXP:({DATETICKS} - {DEC:~CommandStarted}) < 300000000}] Equals '1'
        Write '[Purple] Command timed out' to log
    End Condition - Exit when condition met
End Loop
Note that the loop is infinite, which is just for the example. The text compare should go inside your existing wait loop.

I'm using the "~" prefix in the variable name, to indicate that it is command-local. This means that different instances of the command will have separate timers, instead of resetting all of them when a new instance starts.

I'm also using the "When this block is reached, exit command if condition is met" option for the "End a Conditional Block" action, so there's no need for an "Exit Command" action.

There are 10000 ticks in a millisecond, 10000000 ticks in a second, so 300000000 ticks is a wait time of 30 seconds.

GreyArea

  • Newbie
  • *
  • Posts: 34
Re: Background process load
« Reply #2 on: March 20, 2017, 03:10:14 pm »
Interesting...I was thinking of using the time variables...set time loop started, and Say "are you still there"? at minute intervals...

I think I need to add a "Forgert I said anything" response to cancel it :-)