March 2, 20178 yr 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?
March 2, 20178 yr 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
March 2, 20178 yr 4 minutes ago, Juggles said: Don't use webWalk ^ Define static paths if you can, it's helped me manage my resources a lot. Look out for NPE's in the debugger aswell
March 2, 20178 yr 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.
March 2, 20178 yr Author 12 minutes ago, Juggles said: Don't use webWalk Interesting. Can you explain why not? Should I use WalkingEvents instead?
March 2, 20178 yr Just now, Adept said: Interesting. Can you explain why not? Should I use WalkingEvents instead? Just look at your memory before and after webwalker is called
March 2, 20178 yr 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 : There are many ways to accomplish this, so don't limit yourself to my method. I generally write scripts in a rush Edited March 2, 20178 yr by Abuse
March 2, 20178 yr 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
March 2, 20178 yr To use States isn't faster or less resource expensive... It's just cleaner to read... If you look at the code it's slower and uses more resources.
March 2, 20178 yr 34 minutes ago, Soldtodie said: To use States isn't faster or less resource expensive... It's just cleaner to read... If you look at the code it's slower and uses more resources. Exactly what I mean, having code that is clean to read will result in it being easier to find the bottleneck.
March 2, 20178 yr Just now, Abuse said: Exactly what I mean, having code that is clean to read will result in it being easier to find the bottleneck. how do you use paths? http://explv.github.io/ format for paths gives me an error when i try to use
March 2, 20178 yr Author I'm afraid I can't share my source code since it's a private method. Thanks to all those who've shared some insight! I'll go through the code and amend according to your recommendations. Edited March 2, 20178 yr by Adept
March 2, 20178 yr 11 minutes ago, Lewis said: how do you use paths? http://explv.github.io/ format for paths gives me an error when i try to use Paths have to be in List format now iirc, you can change the output type on my map by clicking the cogwheel
March 2, 20178 yr Just now, Explv said: Paths have to be in List format now iirc, you can change the output type on my map by clicking the cogwheel btw your map thing is glitching for me now, when i move the map it blacks out like so now i cant select a path or area
Create an account or sign in to comment