Code: Select all
local socket = require("socket")
local s = socket.gettime()
t = {}
local function g(t)
t = math.random(1, 100)*math.random(1, 100)*math.random(1, 100)
end
for i=1, 8000000 do
-- Line A
--t[1] = math.random(1, 100)*math.random(1, 100)*math.random(1, 100)
-- Line B
g(t[1])
end
print(math.abs(s-socket.gettime()))
Shouldn't the function overhead make 'Line B' slower?
Also, how do you feel about using functions inside performance critical code?
Do you tend to avoid them? Or does it not really matter to you?