ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Crisis on July 01, 2013, 09:15:26 PM

Title: set #lpc What does it do?
Post by: Crisis on July 01, 2013, 09:15:26 PM
What does this command do? I see it used a lot and I see it usually as set #lpc 100 and a few times as set #lpc 200.

Thanks!!
Title: Re: set #lpc What does it do?
Post by: TrailMyx on July 01, 2013, 09:32:00 PM
LPC stands for lines per cycle.  The standard EUO script runs at 10 lines per cycle.  You can override the standard execution speed to allow your script to run quicker then it normally can.  Having a higher LPC effects other running scripts and will increase your overall performance.  So you should keep your LPC as low as possible.   You'll notice some scripts will bump the LPC up to very large values, but that should only be temporary for evaluation of specific instances.

Edit.  Cycle, not second.  Don't try answering questions when you're drunk.  lol
Title: Re: set #lpc What does it do?
Post by: Crome969 on July 01, 2013, 11:06:16 PM
LPC stands for lines per second.  The standard EUO script runs at 20 lines per second.  You can override the standard execution speed to allow your script to run quicker then it normally can.  Having a higher LPC effects other running scripts and will increase your overall performance.  So you should keep your LPC as low as possible.   You'll notice some scripts will bump the LPC up to very large values, but that should only be temporary for evaluation of specific instances.

If i remember right, it also use more cpu\memory so you will loose a few ressource.
Title: Re: set #lpc What does it do?
Post by: manwinc on July 02, 2013, 04:38:50 AM
Pretty much exactly what TM Said. Unless you are Crunching large Amounts of Data, or Pixel scanning Bunches of Pixels, you don't really need to take your #Lpc above 100. Once your CPU starts Capping out on your Computer EUO starts Slowing Way Down, making your #Lpc Pointless.
Title: Re: set #lpc What does it do?
Post by: ximan on July 02, 2013, 08:51:48 AM
Right, you want to use as low a #lpc as you can get away with.  However, load increase depends upon what is happening in the code, try running these three snippets in turn while monitoring your cpu usage with each:

Code: [Select]
set #lpc 200
set %a 1
while #true
{
  set %a %a + 1
}

Code: [Select]
set #lpc 200
set %a 1
while #true
{
 finditem *
  set %a %a + 1
}

Code: [Select]
set #lpc 200
set %a 1
while #true
{
 finditem *
  set %a %a + 1
  sleep 10
}

The reason I cranked up #lpc in your script was to run boiler plate (pure data manipulation, menu, and control flow) code as quickly as possible in order to increase UI responsiveness and to measure how long craft gumps disappeared when an item was created.  You can set it lower if it is causing problems, however most simple scripts tend spend a majority of their time waiting to do something cyclical, and such waits tend to break up the cpu utilization into bursts, regardless of the #lpc setting.

Title: Re: set #lpc What does it do?
Post by: manwinc on July 02, 2013, 10:15:04 AM
Nah, you're fine at 200. I think I actually do 9999 in my Cont_Timer Sub. There are a few gumps in UO that once they pop up, its impossible to force them to be the Topmost gump again, so you need to react pretty quickly.


What a lot of coders will do with their subs is set a variable to what the #LPC was at the start of their sub, increase the LPC, and then Reset it at the End of it.


Sub DO_Something
Namespace Push
Namespace Local DO_Something
set !LPC #LPC
set #LPC 200
; DO Something
set #LPC !LPC
Namespace Pop
Return
Title: Re: set #lpc What does it do?
Post by: TrailMyx on July 02, 2013, 10:18:46 AM
Another thing to think about is how your LPC effects the operation of other scripts.  An instance of EUO seems to share from a pool of performance.  So if you are hogging the LPC with a script, it will make the other scripts run slower.  I probably have some examples somewhere when I was testing this, but it's pretty easy to modify what Ximan posted to convince yourself that you should be a good scripting neighbor.