Optimizing Expressions

Moderators: Disciple, zlovatt

Post Reply
Posts: 20
Joined: January 17th, 2007, 3:02 pm

June 6th, 2013, 6:50 am

Hey everyone,

I'm looking for ways to optimize the speed of evaluating expression. I am fine with losing readability as long as things evaluate quicker. From some experimenting, it looks like

Code: Select all

var1 = effect("Slider Control")("Slider");
var2 = effect("Slider Control 2")("Slider");
[var1, var2]
evaluates slower than

Code: Select all

[effect("Slider Control")("Slider"), effect("Slider Control 2")("Slider");]
which makes sense, because we're not wasting time creating and assigning a variable.

However, what about in this example, where the variable is used more than once...

Code: Select all

var1 = effect("Slider Control")("Slider");
randomVar = random(-var1, var1)
[randomVar, randomVar]
Does that evaluate slower than this?

Code: Select all

randomVar = random(-effect("Slider Control")("Slider"), effect("Slider Control")("Slider"))
[randomVar, randomVar]

Basically, I'm wondering in general, if a property is going to be used more than once is it worth the calculation time creating a variable, opposed to looking up the value?

Any other optimization advice is appreciated as well.
Posts: 3
Joined: October 4th, 2014, 7:36 pm

October 9th, 2014, 4:09 am

I'm wondering what ways can I optimize the evaluating expression speed. I badly need your help as well.
Post Reply