Jump to content

check for animation playing or just restart?


Quarrel Kukulcan
 Share

You are about to reply to a thread that has been inactive for 1397 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Option A: Check whether an animation is playing and only restart it if it isn't.

Option B: Just fire off llStartAnimation(). If the animation is already running, it'll simply keep going (not jump back to the beginning).

Does Option A have significantly less server load?

 

Edited by Quarrel Kukulcan
Link to comment
Share on other sites

10 hours ago, Wulfie Reanimator said:

Define "significantly" and keep in mind we have no way to measure this.

Q: Why is option A necessary?

Jeez, I don't have a professional certification metric in mind. At least 25% less? I'm trying to avoid writing laggy scripts. "Don't do something you don't need to" is one very basic element of optimizing performance, but it looks like this is a case where checking whether I need to do something is plausibly as slow as or slower than just doing it.

Link to comment
Share on other sites

38 minutes ago, Quarrel Kukulcan said:

Jeez, I don't have a professional certification metric in mind. At least 25% less? I'm trying to avoid writing laggy scripts. "Don't do something you don't need to" is one very basic element of optimizing performance, but it looks like this is a case where checking whether I need to do something is plausibly as slow as or slower than just doing it.

It's gonna be tough to say (at least I have no idea), since either choice is likely to create a cascade of new tasks for the sim.

I guess you could try the old efficiency tester: http://wiki.secondlife.com/wiki/LSL_Script_Efficiency

But I'm of the mind that premature optimization is objectively bad. Does that 25% difference matter? How significant is 25%? (25% of 0.02ms vs 0.005ms) Is it the biggest slow-down in the script? Does it happen frequently? (How frequently does it happen?)

I would personally always favor readable code (or less code), even if it costs me some speed or memory. And as much as I like to obsess about "low-lag" while thinking about scripting, I don't think you'd realistically notice any difference between the two versions of your script.

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

There is no need to check if an animation that is supposed to be playing is playing first before playing it again unless you're wanting to add diagnostics to check for when/how often the scenario occurs.

I've had to replace bento ear/tail scripts with ones that periodically play the intended animation to counter issues of animation loss which can happen when using the viewer's Reset Skeleton & Animations option or when a particular bug occurs when detaching/standing from an object that requested animation permissions.

  • Like 1
Link to comment
Share on other sites

The call to llStartAnimation() etc., I would say are very efficient, what you need to be observant on, is how you do the check with your script.

For example just to emphasize some terrible approaches (never do); a continuous polling of animations - be it in a for loop, while condition never meet, or fast timer calling - add to this the permissions checks.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1397 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...