PDA

View Full Version : Clock Script Speed


Stoehr
03-13-2009, 06:08 AM
How can I test the speed of my scripts? I've been able to make several solutions to the same problem, but I'm wondering which script is faster. Thanks in advance!

Edit: Here's the code i want to compare. I'm matching a child's transforms to its parent.

Option 1 - Command Model

MatchTransform(child, parent, siSRT);

Option 2 - Object Model

function ffMatchParent(oChild){
var h = oChild.kinematics.local;
h.sclx.value = 1;
h.scly.value = 1;
h.sclz.value = 1;
h.rotx.value = 0;
h.roty.value = 0;
h.rotz.value = 0;
h.posx.value = 0;
h.posy.value = 0;
h.posz.value = 0;
}

//another variation, just shorter, and uses transforms
function fMatchParent(oChild){
oNewLocalTransform = XSIMath.CreateTransform();
oNewLocalTransform.SetTranslationFromValues(0, 0, 0);
oNewLocalTransform.SetRotationFromXYZAnglesValues(0, 0, 0);
oNewLocalTransform.SetScalingFromValues(1, 1, 1);
oChild.Kinematics.Local.Transform = oNewLocalTransform;
}



Option 3 - Object Model - Enumerated


function fMatchParent(oChild){
var oParams = oChild.Kinematics.Local.Parameters;
var oLocal = oChild.Kinematics.Local;
var e = new Enumerator( oParams );
var n = 0;
for (;!e.atEnd();e.moveNext()){
//trace("{ "+ n +" }" + e.item());if(n == 2){trace(e.item(n));}
switch(n){
case 2:
e.item().value = 0;
break;
case 3:
e.item().value = 0;
break;
case 4:
e.item().value = 0;
break;
case 5:
e.item().value = 0;
break;
case 6:
e.item().value = 0;
break;
case 7:
e.item().value = 0;
break;
case 12:
e.item().value = 1;
break;
case 13:
e.item().value = 1;
break;
case 14:
e.item().value = 1;
break;
default:
break;
}
n++
}
}

Stoehr
03-13-2009, 06:46 AM
The "trace" I'm using requires this function.


function trace(oMessage){
Application.LogMessage(oMessage);
}


Sometimes I accidentally type Actionscript because of my experience in Flash, so I wrote this to protect me.

Stoehr
03-13-2009, 09:00 AM
Well, never mind. I did find a solution (http://softimage.wiki.softimage.com/index.php/Loopin%27_Lizards%21_A_Comparison_of_Techniques_for_Looping_through_Properties).


s = new Date();

//do stuff

t = new Date();
LogMessage("Direct Pointer: " + (t-s)/1000);

Stoehr
03-13-2009, 09:18 AM
here are the results.

//MatchTransform
// INFO : Total time: 2.103

//Object Model
// INFO : Total time: 1.28

//Object Model - enumerated --> EDIT: Correction, there's no difference in speed, this version is just more lines of code.
// INFO : Total time: 1.28

CGTalk Moderation
03-13-2009, 09:18 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.