the outer code is available hereRobin wrote:How does the outer code look like?
rhezalouis wrote:[RLC]"Regarding Time Measurement"
I assume the localizations is happened inside the love.draw() so that it would also called every cycle, so I put it inside the loop to simulate it. But, If you're lucky, sometimes even when the localization is put into the loop, the data could yield a better time average... .Robin wrote:
- If the local b ... part was inside the loop, it is logical it is slower: it gives something like GETGLOBAL, GETDOTTED, SETLOCAL, GETLOCAL, CALL in byte code rather than GETGLOBAL, GETDOTTED, CALL. There should be an improvement in performance if you move the local b = math.sqrt outside the loop.
Hell, things are getting more weird:Robin wrote:[*]I'm not sure about this, but the Lua compiler might optimize constant expressions like 2^0.5. Change it to x^0.5 (where x is defined earlier to be a local with value 2) to see if it changes the outcome.[/list]
Code: Select all
local x = 2; local b = math.sqrt;[outside the loop]
a = math.sqrt(x) >> t avg = 3359.2µs [control]
a = b(x) >> t avg = 3300.6µs [2%faster than control t]
local c = math.sqrt; a = c(x); >> t avg = 1738.2µs [48%faster than control t]
a = x^0.5; >> t avg = 3906µs [16%SLOWER than control t!]