The following chapter discusses some general rules and approaches to get the maximum speed out of your code. A MAXScript could do the job as expected but it could do it very slowly or very quickly depending on the writing style of the developer.
In addition, optimizing a script for speed often leads to a cleaner code that is easier to read by others and to maintain by the developer.
Disable Viewport Redraws when making changes to scene objects
Disable Undo system when possible
Modify Panel can be slow - change to Create Panel when possible
Use the 'flagForeground' node viewport state method
Never get a single pixel when you can get a whole line
Only calculate once if possible
Cache frequently used functions and objects
Dice your data into smaller pieces
Use bitArrays instead of Arrays when possible
Pre-initialize arrays when final size is known
Recursive functions can be faster
matchPattern is faster than findString
Do not use return, break, exit or continue
Use StringStream to build large strings
Use name values instead of strings when possible
Try not to use Execute function if there is an alternative
For Loop By Index Vs For Loop Through Collection Performance
For Loop Collect Vs For Loop Do Performance
Optimizing Particle Flow Script Operator For Loops For Speed