Alright… here’s a few I recall off the top of my head - haven’t dug into my scripts to find old comments on oddball speed-ups.
At one point I needed random point3 integers, lots and lots of them. The problem is, random <point3> <point3> makes the values within those point3s floats.
So…
startTime = timeStamp()
for i = 1 to 3000000 do (
randP3 = random [0,0,0] [10,10,10]
randP3.x = randP3.x as integer
randP3.y = randP3.y as integer
randP3.z = randP3.z as integer
)
format "time: %
" ((timeStamp() - startTime) / 1000.0)
time: 16.854
startTime = timeStamp()
for i = 1 to 3000000 do (
randP3x = random 0 10
randP3y = random 0 10
randP3z = random 0 10
randP3 = [randP3x,randP3y,randP3z]
)
format "time: %
" ((timeStamp() - startTime) / 1000.0)
time: 12.629
Subtle, but I actually had to generate tens of millions; becomes a little less subtle. This is on a slower machine, though 
Here’s another favorite… UI updates. UI updates are slow.
ProgressBars are a very popular method of showing, well, progress. But updating them all the time is slow. Update them only periodically. For example, only if the update would actually show in the progress bar (depending on its width).
rollout test "test" (
progressbar pb_test
)
createDialog test
pb = test.pb_test -- pre-initialize, lest we incur a speedhit for getting it from the rollout all the time.
startTime = timeStamp()
for i = 1 to 1000000 do (
pb.value = (i / 1000000.0) * 100
)
format "time: %
" ((timeStamp() - startTime) / 1000.0)
time: 29.012
startTime = timeStamp()
for i = 1 to 1000000 do (
if (mod i 7500 == 0) then ( -- 7500 in this case depending on progressbar width of 133px
pb.value = (i / 1000000.0) * 100
)
)
pb.value = 100 -- make sure it does read 100% at the end
format "time: %
" ((timeStamp() - startTime) / 1000.0)
time: 2.043
-- lets' get rid of that mult as well
startTime = timeStamp()
for i = 1 to 1000000 do (
if (mod i 7500 == 0) then ( -- 7500 in this case depending on progressbar width of 133px
pb.value = (i / 10000.0)
)
)
pb.value = 100
format "time: %
" ((timeStamp() - startTime) / 1000.0)
time: 1.943
Another one, no code for obvious reasons… f you have an intense loop with a lot of if-tests to validate a value; for example to prevent OOB accesses or so, consider try/catch. Typically try/catch is slower than if-tests, but with enough if-tests, try/catch may just win. Pretty rare, and probably not recommended practice; but if you’re going for speed…
An old favorite… always name the objects you create, as max will otherwise waste time trying to find a unique name for the new object (obviously only do this if you have no fear of creating non-unique names). This assumes cloneNodes cannot be used for whatever reason.
delete objects
startTime = timeStamp()
undo off (
for i = 1 to 5000 do (
newSphere = geoSphere()
)
)
format "time: %
" ((timeStamp() - startTime) / 1000.0)
time: 60.226
delete objects
startTime = timeStamp()
undo off (
for i = 1 to 5000 do (
newSphere = geoSphere name:("mySphere" + i as string)
)
)
format "time: %
" ((timeStamp() - startTime) / 1000.0)
[color=Blue]time: 34.149[color=#fffffe]
[/color][/color]