Jump to content
Adept

Script optimisations to reduce lag

Recommended Posts

I've noticed that the client lags considerably when running my script.
What measures can I take to ensure that my script consumes as little resources as possible?
I've increased the onLoop counter to reduce loops per minute and am also using a series of "else if" conditional statements instead of a series of "if" statements to reduce the number of conditions checked.

What else can I do?

Link to comment
Share on other sites

7 minutes ago, Adept said:

I've noticed that the client lags considerably when running my script.
What measures can I take to ensure that my script consumes as little resources as possible?
I've increased the onLoop counter to reduce loops per minute and am also using a series of "else if" conditional statements instead of a series of "if" statements to reduce the number of conditions checked.

What else can I do?

It would be helpful if you showed us the source code so we can tell you where you are going wrong.

Also in the future please post in the Scripting Help section

  • Like 1
Link to comment
Share on other sites

chances are that if your code is really laggy, using else ifs vs. ifs wont really help. you're probably doing an inefficient calculation or something that takes a ridiculous amount of time, either in your onLoop() or onPaint(). also check that you're not getting any exceptions

if you want specific help, you'll need to post your source code.

  • Like 1
Link to comment
Share on other sites

41 minutes ago, Juggles said:

Don't use webWalk 

I think that the user means CPU usage, webWalking isn't very CPU intensive after it calculates the route. It does consume 200-300MB ram, but that is to be expected

First of all, I'd suggest to use ConditionalSleeps where applicable. Many beginning scripters tend to put their codebase into one giant loop with a lot of condition checking

A smarter way is to split up your script into 'Tasks' or 'States' paired with a getTask(), getState(), or similar.

When a task has been executed you conditionalsleep until a certain condition is met (or it times out). Using this method I can easily run 50 clients on a modern quad core CPU

Something along the lines of :

uiYWLdi.png

O35SViy.png

V3dRTzl.png

XWAKqxz.png

There are many ways to accomplish this, so don't limit yourself to my method. I generally write scripts in a rush :boge:

Edited by Abuse
  • Like 2
Link to comment
Share on other sites

4 minutes ago, Abuse said:

I think that the user means CPU usage, webWalking isn't very CPU intensive after it calculates the route. It does consume 200-300MB ram, but that is to be expected

First of all, I'd suggest to use ConditionalSleeps where applicable. Many beginning scripters tend to put their codebase into one giant loop with a lot of condition checking

A smarter way is to split up your script into 'Tasks' or 'States' paired with a getTask(), getState(), or similar.

When a task has been executed you conditionalsleep until a certain condition is met (or it times out). Using this method I can easily run 50 clients on a modern quad core CPU

 

 

would like to know more
i use states and still get a high cpu/ram usage

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...