12-26-2015, 11:02 PM
(12-26-2015, 09:56 PM)NiLSPACE Wrote: I found another reason for moving to LuaJit. Accessing tables is much faster making OOP much faster. Accessing a method in a table 1.000.000.000 times took 93.534 seconds in Lua, while it only took 0.425 seconds in LuaJit.
Now, naturally it won't happen allot that a plugin would call a method a billion times, but in the WorldEdit plugin I sometimes had to define a function locally instead of calling it from the table because the performance impact would otherwise be too great.
Try creating a local reference to the method before calling it 1,000,000,000 times. I believe you'd get very similar performace.
e.g.
Code:
local foo = myTable.Function;
for i = 0, 1000000000 do
foo()
end
In general, Lua is much faster with locals. I don't think this justifies LuaJit. Just make a local before a tight loop.