Yes, LÖVE 0.10.1 uses LuaJIT.
I can't reproduce your results without using a profiler. Maybe the profiler is disabling optimization or forcing some extra calls.
Here's my test program (yours with a few changes):
Code: Select all
require 'socket'
local TABL_TEST = { }
for i = 1, 10000 do
TABL_TEST[i] = { math.random(),
math.random(),
math.random(),
math.random(),
math.random(),
math.random(),
math.random(),
math.random(),
math.random()
}
end
local function methodA(TABL_TEST)
for i = 1, #TABL_TEST do
TABL_TEST[i][1] = TABL_TEST[i][1] + TABL_TEST[i][2] + TABL_TEST[i][3] + TABL_TEST[i][4] + TABL_TEST[i][5] + TABL_TEST[i][5] + TABL_TEST[i][6] + TABL_TEST[i][7] + TABL_TEST[i][8] + TABL_TEST[i][9]
end
end
local function methodB(TABL_TEST)
for i = 1, #TABL_TEST do
local item = TABL_TEST[i]
item[1] = item[1] + item[2] + item[3] + item[4] + item[5] + item[5] + item[6] + item[7] + item[8] + item[9]
end
end
local startTime = socket.gettime()
for i = 1, 10000 do
methodA(TABL_TEST)
end
print(socket.gettime() - startTime)
(change methodA to methodB to test the other)
Run with either 'luajit main.lua' or 'love .'
Results of 10 runs of each:
Code: Select all
methodA methodB
0.87791299819946 0.87835216522217
0.8876838684082 0.87647485733032
0.88603281974792 0.88520693778992
0.89042115211487 0.89626216888428
0.90008997917175 0.88968300819397
0.89558506011963 0.88830399513245
0.89924907684326 0.88235592842102
0.87286520004272 0.89468812942505
0.86974000930786 0.88487601280212
0.87221884727478 0.88938403129578
The differences are not distinguishable from noise.
I changed the assignment to prevent LuaJIT from realizing that the value is not used, and discard the whole operation. Making the result visible from outside the function should stop that.