View Full Version : Maxscripts slower than C++ plugins
shibumenon 06-12-2006, 05:43 AM Can someone shed light on why a plugin written in C++ turns out to work
faster than a similar one written in maxscript?
thanks
shibu
|
|
mobeen
06-12-2006, 06:20 AM
Can someone shed light on why a plugin written in C++ turns out to work
faster than a similar one written in maxscript?
thanks
shibu
The difference is that of a compiled and interpreted code. Maxscript code is interpreted by the maxscript compiler whereas the C++ code is compiled thus it is executed straightaway.
Think of maxscript as a series of instructions that you are giving to another program (the maxscript compiler) that then performs the instructions given to it. This interpretation of the maxscript is what is the cuase of the delay.
Hope this clarifies the issue a great deal
Thanks
Mobeen
Wahooney
06-12-2006, 08:02 AM
Just to put in in perspective, I did a simple arithmetic test a while ago, showing C++ vs MXS. A variable is initialised, and over 5 million iterations 0.01 is added to it, so basically:
for (int i=0; i<5000000; i++) f += 0.01f;
vs
for i = 1 to 5000000 do f += 0.01
on my machine the C++ code executes in 43ms where the maxscript ran in +/- 10000ms!
But like mobeen says, it's a compiled vs interpreted program problem. When C++ adds 2 numbers it pretty much hands the problem directly to the processor, where when maxscript adds two numbers it hands the problem to the interpreter which then basically translates it and then hands it to the processor.
Maxscript could definitely get a speed boost though because Lua runs the same test in about 450ms, granted it has less features than maxscript, but arithmetic is arithmetic ;)
Jeff_hanna
06-12-2006, 02:58 PM
There's also the difference in that the SDK works at a much lower level in Max than MaxScript. For many MaxScript methods you're essentially locked into user-space which means performance is constrained by viewport redraws, command panel updates, and the such.
CGTalk Moderation
06-12-2006, 02:58 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.