Adept Posted March 2, 2017 Share Posted March 2, 2017 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? Quote Link to comment Share on other sites More sharing options...
Explv Posted March 2, 2017 Share Posted March 2, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
Juggles Posted March 2, 2017 Share Posted March 2, 2017 Don't use webWalk 2 Quote Link to comment Share on other sites More sharing options...
IHB Posted March 2, 2017 Share Posted March 2, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
Team Cape Posted March 2, 2017 Share Posted March 2, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
Adept Posted March 2, 2017 Author Share Posted March 2, 2017 12 minutes ago, Juggles said: Don't use webWalk Interesting. Can you explain why not? Should I use WalkingEvents instead? Quote Link to comment Share on other sites More sharing options...
Juggles Posted March 2, 2017 Share Posted March 2, 2017 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 2 Quote Link to comment Share on other sites More sharing options...
Abuse Posted March 2, 2017 Share Posted March 2, 2017 (edited) 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, 2017 by Abuse 2 Quote Link to comment Share on other sites More sharing options...
Lewis Posted March 2, 2017 Share Posted March 2, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
Soldtodie Posted March 2, 2017 Share Posted March 2, 2017 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. 2 Quote Link to comment Share on other sites More sharing options...
Abuse Posted March 2, 2017 Share Posted March 2, 2017 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. 2 Quote Link to comment Share on other sites More sharing options...
Lewis Posted March 2, 2017 Share Posted March 2, 2017 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 Quote Link to comment Share on other sites More sharing options...
Adept Posted March 2, 2017 Author Share Posted March 2, 2017 (edited) 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, 2017 by Adept 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted March 2, 2017 Share Posted March 2, 2017 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 Quote Link to comment Share on other sites More sharing options...
Lewis Posted March 2, 2017 Share Posted March 2, 2017 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 Quote Link to comment Share on other sites More sharing options...