The Basics Of Basic Optimization


#21

Wasn't all of your data pre-calculated in that? That would probably mean that the slowest bit is just looking up data and setting properties; which would make sense that doing what you did made it faster.

For code which does lots of calculations, (e.g. inverse kinematics, physics simulation, etc.) BlueTaslem's points make a lot more sense as they affect the speed much more.


#22

The data is, but the actual things like the UDim2s aren't. About 64 are created per 1/60 of a second, so storing the index for UDim2.new does prevent a lot of those calls.


#23

Generally speaking, you don't want to optimize for things that aren't a problem.
The usual workflow I've seen is to write code/features, run a profiler and work specifically on the problematic areas.

In roblox, the tools for this are somewhat lacking and poorly documented (something I'd like to fix in the near future), but the Micro Profiler will get you an idea of what's taking the most time.

It's usually not anything lua related.


#24

Some tips I found online ( some don't apply to ROBLOX ):

http://forums.civfanatics.com/showthread.php?t=463488


#25

Are these two ways of setting up a local function just as effective as each other?

local This = function()
---stuff
end
local function This()
---stuff
end

#26

Both are defining local variables to be that function, so yes.


#27

Okay that’s good, thanks for making this tutorial.


#28

This times a bunch.


#29

There is a difference.

local This = function()
	print(This)
end
local function This()
	print(This)
end
local This; This = function()
	print(This)
end

The first prints nil; this will not work as a recursive function. The second two print the function and can be used recursively.