package.path = package.path .. ";D:/Ripple WIP/Ripple_New/GameLogic/Base/?.lua" package.path = package.path .. ";D:/Ripple WIP/Ripple_New/GameLogic/Instance/?.lua" require("Actor"); require("GameInstance"); local bob = Actor:New(o, "bob") bob.modules["test"] = Module:New(o, bob, "test", "test") bob.modules.test.moduleCommands["testcommand"] = Command:New() bob:ProcessUpdate() local gameInst = GameInstance:New(); local id = gameInst:AddActor(bob); print(gameInst.actorList[id].name); bob.name = "bobbythe2nd" print(gameInst.actorList[id].name); print(id); gameInst:RemoveActor(id); local gone = gameInst.actorList[id] == nil; print(gone); print(bob.name); --stress test local stresstest = function (times) for i=times,1,-1 do local actor = Actor:New(o, math.random(10000000), math.random(10000000)) for p=times,1,-1 do local module = Module:New(o, actor, math.random(10000000), math.random(10000000)); for k=times,1,-1 do local command = Command:New(); module:AddCommand(command); end actor:AddModule(module); end gameInst:AddActor(actor); end end local test2 = function() local oldPrint = print; print = function (string) end GameInstance:Update(); print = oldPrint; end do local units = { ['seconds'] = 1, ['milliseconds'] = 1000, ['microseconds'] = 1000000, ['nanoseconds'] = 1000000000 } function benchmark(unit, decPlaces, n, f, ...) local elapsed = 0 local multiplier = units[unit] for i = 1, n do local now = os.clock() f(...) elapsed = elapsed + (os.clock() - now) end print(string.format('Benchmark results: %d function calls | %.'.. decPlaces ..'f %s elapsed | %.'.. decPlaces ..'f %s avg execution time.', n, elapsed * multiplier, unit, (elapsed / n) * multiplier, unit)) end benchmark("milliseconds", 5, 100, stresstest, 100) benchmark("seconds", 5, 1, test2) end