reForm

12-23-2008, 05:16 PM

<edit>

To save you reading through this thread, head over to http://www.tech-artists.org/wiki/Performance_Tests_(MAXScript) (http://www.tech-artists.org/wiki/Performance_Tests_%28MAXScript%29) where there are extensive code speed comparisons

</edit>

Hi,

After watching some of Bobo's cgacademy video on The Matrix, it occured to me that there are quite a few functions I've been using that could have been scripted directly. With that thought I checked to see the speed comparison. My first test was using the cross product to calculate area rather than the meshop.getfacearea command. The results were surprising in one way, but I guess to be expected!

With 10000 iterations:

meshop.getfacearea = 0.281 seconds

cross product method = 0.11 seconds

That to me is a substantial difference.

Maybe it would be helpful for everyone if we added scripted versions of standard maxscipt functions that offered similar speed advantages to this thread. Along with the geometric functions sticky I think this could be a handy resource.

Here's the code for the area speed test that you can use as a basis for future speed tests. :)

theobj=$plane01 --You will need to make this plane and convert to editable_mesh!

theface = getface theobj 1

thevert1 = getvert theobj theface.x

thevert2 = getvert theobj theface.y

thevert3 = getvert theobj theface.z

thevector1 = thevert2 - thevert1

thevector2 = thevert3 - thevert1

iterations=100000

fn area1 = (

for i = 1 to iterations do thearea1 = (length (cross thevector1 thevector2))/2

)

fn area2 = (

for i = 1 to iterations do thearea2 = (meshop.getfacearea theobj 1)

)

start = timeStamp()

area1() -- do some big job

end = timeStamp()

format "Processing area1 took % seconds\n" ((end - start) / 1000.0)

start = timeStamp()

area2() -- do some big job

end = timeStamp()

format "Processing area2 took % seconds\n" ((end - start) / 1000.0)

To save you reading through this thread, head over to http://www.tech-artists.org/wiki/Performance_Tests_(MAXScript) (http://www.tech-artists.org/wiki/Performance_Tests_%28MAXScript%29) where there are extensive code speed comparisons

</edit>

Hi,

After watching some of Bobo's cgacademy video on The Matrix, it occured to me that there are quite a few functions I've been using that could have been scripted directly. With that thought I checked to see the speed comparison. My first test was using the cross product to calculate area rather than the meshop.getfacearea command. The results were surprising in one way, but I guess to be expected!

With 10000 iterations:

meshop.getfacearea = 0.281 seconds

cross product method = 0.11 seconds

That to me is a substantial difference.

Maybe it would be helpful for everyone if we added scripted versions of standard maxscipt functions that offered similar speed advantages to this thread. Along with the geometric functions sticky I think this could be a handy resource.

Here's the code for the area speed test that you can use as a basis for future speed tests. :)

theobj=$plane01 --You will need to make this plane and convert to editable_mesh!

theface = getface theobj 1

thevert1 = getvert theobj theface.x

thevert2 = getvert theobj theface.y

thevert3 = getvert theobj theface.z

thevector1 = thevert2 - thevert1

thevector2 = thevert3 - thevert1

iterations=100000

fn area1 = (

for i = 1 to iterations do thearea1 = (length (cross thevector1 thevector2))/2

)

fn area2 = (

for i = 1 to iterations do thearea2 = (meshop.getfacearea theobj 1)

)

start = timeStamp()

area1() -- do some big job

end = timeStamp()

format "Processing area1 took % seconds\n" ((end - start) / 1000.0)

start = timeStamp()

area2() -- do some big job

end = timeStamp()

format "Processing area2 took % seconds\n" ((end - start) / 1000.0)