View Single Post
08-20-14, 01:42 PM   #13
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Lombra View Post
Well I don't know how this stuff works, but that doesn't seem to be true. I'm guessing it's not to simple as "replacing" the value of the memory address if the new value is much bigger, for example?

Anyway, I got the same results as in your post there, but you forgot the format that people actually use. That is, assigning the values directly instead of declaring the variables separately. Unless I did something wrong, that was a lot faster. (302 vs 546 ms at 100 000 iterations)

Edit: Yup. Upvalues are actually significantly slower.
Code:
local function func()
	return 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9
end

do
	local time = debugprofilestop()

	local q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l
	for i = 1, 1e6 do
		q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l = func()
	end

	print(debugprofilestop() - time)
end

do
	local time = debugprofilestop()

	for i = 1, 1e6 do
		local q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l = func()
	end

	print(debugprofilestop() - time)
end
235 vs. 161 ms.
Intresting, i'm pretty sure i save some improvementss on frequently called cycles with upvaules, at least if you can belive in the actual cpu usage for lua/wow api.
Because if this is true, then whats the point of upvaluing global functions in the main chunk?
  Reply With Quote