[Closed] Compact scripts run slower
Well, if I remove all tabs infront of each line, remove all empty lines and comments, the file becomes smaller so 3ds Max has less to read while executing but it makes the script slower!
Looks like its harder for it to read and understand
Does that make sense?
Davy
It’s difficult to explain why this would happen without knowing what kind of parser and interpreter steps are performed when executing maxscript. But the question is: why would you even want to do it in the first place? Indentation has no syntactic meaning in maxscript, but it does make your code readable, which is important!
Maxscript IS compiled code – it’S NOT interpreted code, thus it would’nt help execution time to remove all the formatting and comments at first hand
Of course it’S not compiled down to assembler code, but it’s definitely not interpreted like good old basic interpreters did it …
Yes, I clearly see a time difference while using both scripts. My working code remains unchanged of course with all comments etc. I thought that cleaning up would make it better in general without any useless lines. That’s how I got into these results.
But I don’t mind, it’s just weird it actually makes a difference in a negative way.
Davy
It’s still hard to believe – at least for me …i’m still sceptical
coud you post two runable code snippets, one feautring comments and formatting, the other one stripped to the core so we could compare ourselfs ?
Did you restart 3ds Max completely before each run ?
The code is too complex. Probably why it can make a difference. I am doing some more tests and will post my final results. I want to know what is causing the slowdown. My working code works quite faster.
I cannot belief it myself either
Looks like it was not an issue with any code optimisation but the slowdown is encryption. The only difference between working code and optimised code (unneeded lines removed) is the slower one is encrypted.
Does that make sense?
Of course, the encrypted one must be un-encrypted in memory before being parsed and executed.
yes , that would explain the difference
but AFAIK this should only be valid for the first time the script is loaded ? Is’nt there some caching in effect under the hood which should keep scripts in memory after they where loaded/executed the first time ?
I think this depends on the script’s structure:
macroscripts would be keept in memory i guess, while simple “load and run” scripts would be loaded, parsed and compiled on demand ( just my speculation… )
if you try to force brute a .mse, max protects that, to avoid hacking…
then maybe it depends on how the .mse runs the code, inside…
to protect the script, MAX maybe constantly decrypting, running, and deleting from memory, I speculate…
I know that in early maxscript versions encryption was only active till Max loaded the file, after that you were able to browse memory regions until you find the sourcecode in plain text. AD improved the encryption a few releases ago, so i think that is not so easy any longer ( but of course still doable for real crackers )
the same, for experienced maxscripters,
To recreate a similar or better script is doable,
likely easier and faster than trying to crack something… ironically.
Anyway nothing beats an optimized script. even if encrypted