|
Post by Thijs on Dec 12, 2015 22:54:07 GMT
Currently, drawing stuff to the screen is very slow and we can't draw very advanced graphics. Please increase the drawing speed to be four times as fast or faster. Copying the draw funtions like 'fillrect=draw.fillrect' improves the speed of drawing, due to lower stack (main chunk in this case). I already used this on my games, it works. You should copy all functions you use math/draw to a main chunk version, which makes it bit by bit faster. the function 'sqrt' is more accessable than 'math.sqrt' setting them to main chunk gains time
|
|
|
Post by warspyking on Dec 13, 2015 2:51:47 GMT
Currently, drawing stuff to the screen is very slow and we can't draw very advanced graphics. Please increase the drawing speed to be four times as fast or faster. Copying the draw funtions like 'fillrect=draw.fillrect' improves the speed of drawing, due to lower stack (main chunk in this case). I already used this on my games, it works. You should copy all functions you use math/draw to a main chunk version, which makes it bit by bit faster. the function 'sqrt' is more accessable than 'math.sqrt' setting them to main chunk gains time Don't forget locals, they're faster
|
|
|
Post by Thijs on Dec 13, 2015 10:51:25 GMT
Copying the draw funtions like 'fillrect=draw.fillrect' improves the speed of drawing, due to lower stack (main chunk in this case). I already used this on my games, it works. You should copy all functions you use math/draw to a main chunk version, which makes it bit by bit faster. the function 'sqrt' is more accessable than 'math.sqrt' setting them to main chunk gains time Don't forget locals, they're faster I know, but main chunk is better when constantly calling a function. And making an own made version of 'math.pow' is slower than the Lua version, I already tested it.
|
|
|
Post by warspyking on Dec 13, 2015 11:33:58 GMT
local pow = math.pow Will be faster then
pow = math.pow
|
|
|
Post by Thijs on Dec 31, 2015 23:48:38 GMT
local pow = math.pow Will be faster then pow = math.pow I don't think it makes a lot of difference; whether you execute it as local in a function (local=faster, in function=slower) or in main_chunk (global=slower, in main_chunk=faster). But I can still test it..
|
|
|
Post by warspyking on Jan 1, 2016 3:42:59 GMT
local pow = math.pow Will be faster then pow = math.pow I don't think it makes a lot of difference; whether you execute it as local in a function (local=faster, in function=slower) or in main_chunk (global=slower, in main_chunk=faster). But I can still test it.. When it's global there is an extra instruction called getglobal or something like that. It's a known fact that locals are faster, albeit a very small difference.
|
|
|
Post by Thijs on Jan 3, 2016 9:53:33 GMT
I don't think it makes a lot of difference; whether you execute it as local in a function (local=faster, in function=slower) or in main_chunk (global=slower, in main_chunk=faster). But I can still test it.. When it's global there is an extra instruction called getglobal or something like that. It's a known fact that locals are faster, albeit a very small difference. Have you noticed main_chunk is faster then in function? That compensates the boost of using local variables, so there is actually little difference.
|
|
|
Post by warspyking on Jan 3, 2016 21:03:13 GMT
|
|
|
Post by chimmihc on Jan 11, 2016 4:19:43 GMT
There is no "main_chunk" in how variable lookup is handled. There are globals with the GETGLOBAL (GETTABUP in 5.2+) instruction, there are upvalues with the GETUPVAL instruction, and there are locals which are grabbed directly off the stack.
Globals are things in the current environment which is _G/_ENV/getfenv() (depending on the version you are using) by default, function scopes (This behaviour is actually expanded in 5.2+ to all scopes instead of just functions with _ENV, which is a completely scoped environment variable) can have custom environments.
Locals are things in the current scope.
Upvalues are locals in an "upper" environment scope (In 5.2+ this still behaves like in the 5.1).
local x = 0 print(x) -- local grab do print(x) -- still local grab end
(function() print(x) -- upvalue grab end)()
|
|