12-26-2015, 11:24 PM
(This post was last modified: 12-26-2015, 11:31 PM by LogicParrot.)
I just tested that. It was ~50 seconds while your original code was 60
Let me try to come up with some hacky way to make the other variable local too, it'd be interesting to compare. Though it would certainly not be tidied code.
This one took 9 seconds:
Let me try to come up with some hacky way to make the other variable local too, it'd be interesting to compare. Though it would certainly not be tidied code.
This one took 9 seconds:
local MyClass = {} function MyClass:new() local Obj = {} setmetatable(Obj, self) self.__index = self Obj.TestVar = math.random(50) return Obj end local startTime = os.clock() local Constr = MyClass:new() local R = Constr.TestVar for I = 1, 1000000000 do R = R + 50 end Constr.TestVar = R print(os.clock() - startTime);You have a point.