PDA

View Full Version : multiplyDivide versus multDoubleLinear

 BigRoyNL02-17-2011, 09:35 PMHey Guys, I've been wanting to check out speed differences between nodes to speed up my autorigger just every tiny bit extra. But I just couldn't seem to find out which exactly of these two nodes was the fastest and came up with the following way to test it. Testing the multDoubleLinear node speed: // testing multDoubleLinear file -f -new; shadingNode -asUtility multDoubleLinear; setAttr "multDoubleLinear1.input1" 1; setAttr "multDoubleLinear1.input2" 1; for (\$x = 2; \$x < 10000; \$x++) { shadingNode -asUtility multDoubleLinear; connectAttr -f ("multDoubleLinear"+(\$x-1)+".output") ("multDoubleLinear"+\$x+".input1"); setAttr ("multDoubleLinear"+\$x+".input2") 2; select -r ("multDoubleLinear"+\$x); } { int \$amountOfRepetitions = 20; int \$amountOfFrames = 10000; float \$timings[]; float \$total = 0; for (\$x = 0; \$x<\$amountOfRepetitions ; \$x++) { timer -s; for (\$i = 0 ; \$i<\$amountOfFrames ; \$i++) { if (`getAttr "multDoubleLinear1.input1"` == 2) { setAttr "multDoubleLinear1.input1" 2; } else { setAttr "multDoubleLinear1.input1" 1; } } \$timer = `timer -e`; print (\$timer+"\n"); \$total = \$total + \$timer; } print ("Total time: "+\$total+"\nAverage Time: "+(\$total/\$amountOfRepetitions)+"\nFPS: "+((\$amountOfRepetitions*\$amountOfFrames)/\$total)+"\n"); } Testing the multiplyDivide node speed: // testing multiplyDivide speed file -f -new; shadingNode -asUtility multiplyDivide; setAttr " multiplyDivide1.input1X" 1; setAttr " multiplyDivide1.input2X" 1; for (\$x = 2; \$x < 10000; \$x++) { shadingNode -asUtility multiplyDivide; connectAttr -f (" multiplyDivide"+(\$x-1)+".outputX") (" multiplyDivide"+\$x+".input1X"); setAttr ("multiplyDivide"+\$x+".input2X") 2; select -r (" multiplyDivide"+\$x); } { int \$amountOfRepetitions = 20; int \$amountOfFrames = 10000; float \$timings[]; float \$total = 0; for (\$x = 0; \$x<\$amountOfRepetitions ; \$x++) { timer -s; for (\$i = 0 ; \$i<\$amountOfFrames ; \$i++) { if (`getAttr " multiplyDivide1.input1X"` == 2) { setAttr " multiplyDivide1.input1X" 2; } else { setAttr " multiplyDivide1.input1X" 3; } } \$timer = `timer -e`; print (\$timer+"\n"); \$total = \$total + \$timer; } print ("Total time: "+\$total+"\nAverage Time: "+(\$total/\$amountOfRepetitions)+"\nFPS: "+((\$amountOfRepetitions*\$amountOfFrames)/\$total)+"\n"); } Giving me the results (on both 10.000 nodes and 10.000 calculations on these connected nodes) The total time is the result of these calculations above done 20 times. The average is for what I said above. multDoubleLinear Total time: 7.472 Average Time: 0.3736 FPS: 26766.59529 multiplyDivide Total time: 10.125 Average Time: 0.50625 FPS: 19753.08642 Oh yeah, the speed difference thus is 0,0000000013 second if you'd just use one for one calculation. :) So. After I did this. I concluded that the multDoubleLinear would in the end be faster (not noticeably really, but interesting result.) But I was wondering if it's indeed right to look at these results, if not: What am I doing wrong? And how can I found out which nodes would be faster for my rig and or for what I'm trying to achieve. How can I test this. Hope somebody knows about this. :) Thanks in advance. Bye, Roy Nieterau
ColinKennedy
02-23-2011, 11:34 AM
Oh, that's interesting! I've never even heard of multDoubleLinear before, good read! Just a quick glance at it though, it'd make sense that multDoubleLinear is faster, its connections and options of operations are restricted to 2 inputs - 1 output and can only be multiplied. The multiplyDivide node has 6 inputs and 3 outputs and you can change the operation. I'm curious though. You're trying to get a fast(er) speed rigger but do your numbers represent actual evaluation speeds as well as the speed it takes to create the nodes? I'm not that technical with Maya so please feel free to correct me if the two are the same. Sorry that I can't really help answer your question.

If so though, here's the more important question - what would be faster, three multDoubleLinear nodes used to multiply the XYZ of two locators and outputing the three individual axes for a 3rd locator's translate (I just used locator as an example of quick input/outputs. It could be anything) or a just single multiplyDivide node?

BigRoyNL
02-23-2011, 01:11 PM
I also thought that the speed difference would be mainly between the actual interface updating of the more 'connections' it has on the multiplyDivide node. It's just that the maya API only starts updating one attribute once it's state is set to dirty, once it has no inputs that change it would be so that those outputs also would not be calculated (as they weren't set dirty.)

If you would take into consideration that indeed it's not calculating the other inputs (Y and Z) and it's actually really slower than three multDoubleLinear nodes would be faster. Though, within rigging je want the most easiest and cleanest setup so I'd still suggest using a multiplyDivide node once you've to do multiplications on things like translation and scale (which are three values, XYZ).

And if I remember correctly once you connect the scale for example to the node it's just one connection. (eg. "scale -> input" instead of "scaleX -> inputX, scaleY -> inputY, scaleZ -> inputY")
It might also get slower because of the more connections.

Oh yeah. As i've said in my initital posts, though there's a significant speed difference between the nodes I've no clue why the difference is there and what exactly is causing it.

I'm still wondering if anyone here knows how this all works and how to really check the speed of nodes over other nodes?

You can do a 'heat' map in the hypergraph: connections editor, but this is still really unclear for such small speed differences like this. (And you don't precisely now what is causing slow-downs.)

Thanks for the reply anyway! If you've more info, please share.

Roy

CGTalk Moderation
02-23-2011, 01:11 PM
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.