Clock Script Speed


#1

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++
   	}
   }
        	
        

#2

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.


#3

Well, never mind. I did find a solution.


s = new Date();

//do stuff

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


#4

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


#5

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.