luaパフォーマンスのデバッグ方法

39779 ワード

luaパフォーマンスのデバッグ方法
         Cocos2dx-lua 3.9   ,         。      。         。      GPU、CPU     。GPU     。         。  CPU                            。                      。   Lua    。                  。   `local type = type`  。                 lua5.1      。  5.3  luaJIT        。     3.9   luaJIT (              Jit    print(jit and jit.version))。             。                 。          。            ,                 。

各関数の実行時間と回数を統計する方法
ネット上で関連資料を探して、この文章の書いたのはまだ分かります.lua性能分析.しかし、私は彼のコードを見つけていません.Githubのこのプロジェクトはなくしたようですが、なぜか分かりません.でも大体どういうことか分かりました.簡単に言えば、C++レベルで2つのコールバック(関数が入る時、退出する時)を経て時間を統計し、実行の前後順に1層1層の印刷対応の対戦を行い、ゲーム中のすべての関数の実行時間の心の中で数え切れない目的を達成することである.彼のソースが見つからなかったからです.しかし、彼がどういう意味なのか分かりました.しかし、私はLua C++部分のコードにあまり詳しくないので、Lua側で手足を作ることにしました.統計関数の実行時間がどれくらいあるかは、同じ目的を達成できるからですが、Lua統計時間を見ればいいです.あまり本気にしないでください.
Luaの関数に統計コードを追加する方法
他の言語にとってはそんなに簡単ではないかもしれませんが、lua言語にとっては簡単です.最も簡単な手段は、元の関数を新しい関数に等しくすることです.新しい関数で計時して元の関数を呼び出せばいいです.くだらないことはもう言わない.直接関連コードを読むと分かりやすいかもしれません
local function PerformanceStatisticsFunction(key, func)
    -- print("PerformanceStatisticsFunction", key)

    return function( ... )
        local current_stack = nil

        local parent_stack = PerformanceStatistics:getInstance()._stack_parent
        local call_stack = PerformanceStatistics:getInstance()._call_stack
        if not parent_stack then
            if not call_stack[key] then
                call_stack[key] = kunpo.TreeNode.new()
            end
            current_stack = call_stack[key]
        else
            current_stack = parent_stack:getChildByName(key)

            if not current_stack then
                current_stack = kunpo.TreeNode.new()
                parent_stack:addChild(current_stack)
            end
        end

        current_stack:setName(key)
        local data = current_stack:getData()
        if data == nil then
            data = {Count = 0, Time = 0}
            current_stack:setData(data)
        end

        PerformanceStatistics:getInstance()._stack_parent = current_stack

        local t0 = GetTimeNow()
        local res = {func(...)}
        local t1 = GetTimeNow()

        PerformanceStatistics.getInstance():statisticsTime(key, t1 - t0)
        PerformanceStatistics.getInstance():statisticsCount(key)

        data.Count = data.Count + 1
        data.Time = data.Time + (t1 - t0)

        PerformanceStatistics:getInstance()._stack_parent = parent_stack

        return unpack(res)
    end
end

そして監視が必要なデータを用意します
プロジェクトのコードの多くはクラスの概念に似た場所に書かれているので、こちらでは関連コンテンツのクラスコンテンツを用意しています.
--          
local WatchItem = 
{
    ["Manager.ArchiveManager"] = kunpo.ArchiveManager,
    ["Manager.BasicDataManager"] = kunpo.BasicDataManager,
    ["Manager.BuffManager"] = kunpo.BuffManager,
    ["Manager.BuffTypeManager"] = kunpo.BuffTypeManager,
    ["Manager.ConfigDataManager"] = kunpo.ConfigDataManager,
    ["Manager.EffectsManager"] = EffectsManager,
    ["Manager.GameManager"] = GameManager,
    ["Manager.LevelManager"] = LevelManager,
    ["Manager.MachineManager"] = MachineManager,
    ["Manager.MapManager"] = MapManager,
    ["Manager.ObjectManager"] = ObjectManager,
    ["Manager.PerCreateManager"] = kunpo.PerCreateManager,
    ["Manager.PerLoadingManager"] = kunpo.PerLoadingManager,
    ["Manager.PortalManager"] = PortalManager,
    ["Manager.RecycleManager"] = RecycleManager,
    ["Manager.RuntimeDataManager"] = kunpo.RuntimeDataManager,
    ["Manager.ShadowManager"] = ShadowManager,
    ["Manager.TaskManager"] = kunpo.TaskManager,
    ["Manager.TaskUIManager"] = TaskUIManager,
    ["Manager.TCDataManager"] = kunpo.TCDataManager,
    ["Manager.UpdateManager"] = kunpo.UpdateManager,
    ["Manager.UpdateWeightManager"] = kunpo.UpdateWeightManager,
}

--       
local table_list = 
{
    ["kunpo.Components"] = kunpo.Components,
    ["kunpo.DataPool"] = kunpo.DataPool,
    ["kunpo.Effects"] = kunpo.Effects,
    ["kunpo.GameData"] = kunpo.GameData,
    ["kunpo.map"] = kunpo.map,
    ["kunpo.ObjectBarrier"] = kunpo.ObjectBarrier,
    ["kunpo"] = 
    {
        ["Bullet"] = kunpo.Bullet,
        ["Character"] = kunpo.Character,
        ["DropItem"] = kunpo.DropItem,
        ["Enemy"] = kunpo.Enemy,
        ["MachineBase"] = kunpo.MachineBase,
        ["Task"] = kunpo.Task,
        ["LimitCondition"] = kunpo.LimitCondition,
        ["LimitCurrentPlayer"] = kunpo.LimitCurrentPlayer,
        ["LimitCurrentPlayerHP"] = kunpo.LimitCurrentPlayerHP,
        ["LimitLevel"] = kunpo.LimitLevel,
        ["LimitSourceChildType"] = kunpo.LimitSourceChildType,
        ["LimitSourceItemId"] = kunpo.LimitSourceItemId,
        ["LimitSourceType"] = kunpo.LimitSourceType,
        ["LimitTargetChildType"] = kunpo.LimitTargetChildType,
        ["LimitTargetItemId"] = kunpo.LimitTargetItemId,
        ["LimitTargetType"] = kunpo.LimitTargetType,
        ["PreConditionLossBlood"] = kunpo.PreConditionLossBlood,
        ["AStar"] = kunpo.AStar,
        ["CommonsLogics"] = kunpo.CommonsLogics,
        ["EventTools"] = kunpo.EventTools,
        ["functions"] = kunpo.functions,
        ["RouteData"] = kunpo.RouteData,
        ["SafeCall"] = kunpo.SafeCall,
        ["SDKHelper"] = kunpo.SDKHelper,
        ["SpriteHelper"] = kunpo.SpriteHelper,
        ["TimeRecord"] = kunpo.TimeRecord,
    },
    ["_G"] = 
    {
        ["Joystick"] = Joystick,
        ["JoystickShot"] = JoystickShot,
        ["Linq"] = Linq,
    },
    ["kunpo.BarrierTools"] = kunpo.BarrierTools,
    ["kunpo.Random"] = kunpo.Random,
}
for key, list in pairs(table_list) do
    for k,v in pairs(list) do
        WatchItem[key.."."..k] = v
    end 
end

for k, item in pairs(WatchItem) do
    PerformanceStatisticsTable(k, GetSourceClass(item))
end

ただし、Cocos 2 dx-luaのクラスの関数は、彼のクラスではないため、追加時にロードできない可能性があります.父のような場所にあるのです元の親を取得し、モニタコードを元の親にロードする方法が必要です.
local function GetSourceClass(t)
    local data = t

    while true do
        if not t then
            break
        end

        if rawget(t, "__cname") then
            break
        end

        local class = rawget(t, "class")

        if class then
            data = class
            break
        end

        local mtable = getmetatable(t)
        if mtable == nil then
            break
        end

        local index = rawget(mtable, "__index")
        if type(index) ~= "table" then
            break
        end

        data = GetSourceClass(index)
        
        break
    end

    return data
end

クラスの初期化は、実際にはクラス内の関数を統計関数に置き換えることです.
local function PerformanceStatisticsTable(tname, t)
    -- print("PerformanceStatisticsTable", tname)
    -- local PrintName = "Manager.ObjectManager"
    -- if tname == PrintName then
    --     print("PerformanceStatisticsTable", tname, t, t.__is_performance_statistics)
    -- end

    local ignore_list = {"ctor", "new", "create"}
    while true do
        if t.__is_performance_statistics then
            break
        end
        t.__is_performance_statistics = true

        for k,v in pairs(t) do

            -- if tname == PrintName then
            --     print(PrintName, k, v)
            -- end

            local item_type = type(v)
            if item_type == "function" and not table.contain(ignore_list, k) then
                t[k] = PerformanceStatisticsFunction(table.concat({tname, k}, "."), v)
            end
        end

        break
    end
end

これらのものは全部できてから.関連する情報を統計する差があります.このフレームのすべてのパフォーマンスデバッグに関する情報を保存する必要があります.
local function GetTimeNow()
    return os.clock()
end 

local output_path = device.writablePath.."Debug"
local lfs = lfs
for file in lfs.dir(output_path) do
    if file ~= "." and file ~= ".." and file ~= ".DS_Store" then
        -- print("DebugOutput", file)
        local file_name = output_path.."/"..file
        os.remove(file_name)
    end
end

local PerformanceStatistics = class("PerformanceStatistics")

local instance = nil

function PerformanceStatistics:getInstance()
    return instance
end

function PerformanceStatistics:ctor( ... )
    self._statistics_time = {}
    self._statistics_count = {}
    self._all_time = 0
    self._print_index = 1000000
    self._call_stack = {}
    self._stack_parent = nil
    -- self._all_time_label = nil
end

-- function PerformanceStatistics:setAllTimeLabel(label)
--      self._all_time_label = label
-- end

function PerformanceStatistics:statisticsTime(name, time)
    self._statistics_time[name] = (self._statistics_time[name] or 0) + time
end

function PerformanceStatistics:statisticsCount(name)
    self._statistics_count[name] = (self._statistics_count[name] or 0) + 1 
end

function PerformanceStatistics:clearLastInfo()
    -- if self._all_time_label then
    --     self._all_time_label:setString(self._all_time)
    -- end

    self._statistics_time = {}
    self._statistics_count = {} 

    -- for k,v in pairs(self._statistics_time) do
    --     self._statistics_time[k] = 0
    -- end

    -- for k,v in pairs(self._statistics_count) do
    --     self._statistics_count[k] = 0
    -- end

    self._call_stack = {}
    self._stack_parent = nil

    self._all_time = 0
end

function PerformanceStatistics:setAllTime(t)
    self._all_time = t
end

function PerformanceStatistics:getAllTime()
    return self._all_time
end

local HeadTab = 3

local function WriteTreeToFile(node, parenttime, deep)
    deep = deep or 0


    local heads = {}
    for i = 1, deep do
        table.insert(heads, "\t")
    end

    local alltime = PerformanceStatistics:getInstance()._all_time

    local data = node:getData()
    io.write(table.concat(heads)..table.concat({string.format("%.3f\t%.3f", data.Time / parenttime, data.Time / alltime), data.Count, node:getName()}, "\t").."
") local childs = node:getChilds() table.sort(childs, function(a, b) return a:getData().Time > b:getData().Time end) for _, item in ipairs(childs) do WriteTreeToFile(item, data.Time, deep + 1) end end function PerformanceStatistics:writeAllInfoToFile() self._print_index = self._print_index + 1 local file_path = device.writablePath.."Debug/"..self._print_index..".txt" io.output(file_path) io.write("self._all_time "..self._all_time.."
") -- local alltime = PerformanceStatistics:getInstance()._all_time for _, item in pairs(self._call_stack) do WriteTreeToFile(item, alltime) io.write("
") end -- io.write("
self._statistics_time
") local output_list = {} for k,v in pairs(self._statistics_time) do table.insert(output_list, {key = k, value = v}) end table.sort(output_list, function(a, b) return a.value > b.value end) for i, item in ipairs(output_list) do local k, v = item.key, item.value io.write(table.concat({v / self._all_time, v, k}, "\t") .. "
") end io.write("
self._statistics_count
") output_list = {} for k,v in pairs(self._statistics_count) do table.insert(output_list, {key = k, value = v}) end table.sort(output_list, function(a, b) return a.value > b.value end) for i, item in ipairs(output_list) do local k, v = item.key, item.value io.write(table.concat({v, k}, "\t") .. "
") end end instance = PerformanceStatistics.new() cc.exports.PerformanceStatistics = PerformanceStatistics

メインループの書き換え
最後に、メインサイクルを書き換え、各フレーム統計をメインサイクルさせ、現在のフレームがタイムアウトした後に現在のフレームのすべての情報を出力する.
local kunpo_components_battlestate_runingupdate = kunpo.Components.BattleState.RuningUpdate
kunpo.Components.BattleState.RuningUpdate = function( ... )
    PerformanceStatistics.getInstance():clearLastInfo()
    local t0 = GetTimeNow()
    kunpo_components_battlestate_runingupdate(...)
    local t1 = GetTimeNow()
    PerformanceStatistics.getInstance():setAllTime(t1 - t0)
    if t1 - t0 > 0.008 then
        PerformanceStatistics.getInstance():writeAllInfoToFile()
    end
end

最後の出力情報の表示方法
まずお手本にしたほうがいいと思います.
self._all_time 0.0092289999999995
0.997	0.997	1	kunpo.Components.BattleState.RuningUpdate
	0.954	0.952	1	Manager.ObjectManager.update
		0.990	0.943	1	Manager.UpdateManager.update
			0.380	0.358	11	kunpo.Components.Movement.update
				0.692	0.248	11	kunpo.Components.LimitMove.limitMove
					0.729	0.181	14	Manager.MapManager.isValidMovement
						0.358	0.065	14	Manager.MapManager.getTileInRect
							0.548	0.036	28	Manager.MapManager.getCoordByPosition
						0.198	0.036	78	Manager.MapManager.getHeightByCoord
							0.279	0.010	78	Manager.MapManager.isOutOfMapByCoord
						0.074	0.013	78	Manager.MapManager.isValidMovementByHeight
						0.059	0.011	14	Manager.MapManager.isOutOfMap
						0.049	0.009	14	kunpo.Components.Collide.isFloating
							0.123	0.001	14	kunpo.Components.Buff.getAttribute
						0.017	0.003	14	kunpo.Components.Collide.getCollide
					0.068	0.017	14	kunpo.Components.Height.getHeight
						0.774	0.013	14	kunpo.Components.Height.getFlyHeight
							0.067	0.001	14	kunpo.Components.Buff.getAttribute
					0.059	0.015	4	kunpo.Components.MessagePack.addMessage
						0.324	0.005	4	kunpo.Components.MessagePack.sortMessages
						0.044	0.001	4	kunpo.Components.MessagePack.addMessageeOnly
						0.015	0.000	4	kunpo.Components.MessagePack.regetSleepTo
					0.025	0.006	4	kunpo.Components.Movement.addExtraForce
					0.018	0.004	11	kunpo.Components.Transformation.getPosition
					0.010	0.003	11	kunpo.Components.Buff.getAttribute
					0.002	0.001	4	kunpo.Components.MessagePack.removeMessage
					0.002	0.001	5	kunpo.Components.Movement.getExtraForce
					0.000	0.000	1	kunpo.Components.LimitMove.setNeedExtrusion
				0.087	0.031	11	kunpo.Components.LimitMove.relieveLimit
					0.587	0.018	1	Manager.MapManager.isValidMovement
						0.160	0.003	1	Manager.MapManager.getTileInRect
							0.815	0.002	2	Manager.MapManager.getCoordByPosition
						0.154	0.003	1	kunpo.Components.Collide.isFloating
							0.038	0.000	1	kunpo.Components.Buff.getAttribute
						0.118	0.002	1	Manager.MapManager.isOutOfMap
						0.018	0.000	1	Manager.MapManager.getHeightByCoord
							0.000	0.000	1	Manager.MapManager.isOutOfMapByCoord
						0.006	0.000	1	kunpo.Components.Collide.getCollide
						0.000	0.000	1	Manager.MapManager.isValidMovementByHeight
					0.174	0.005	1	Manager.MapManager.getHeightByPosition
						0.460	0.002	1	Manager.MapManager.getCoordByPosition
						0.420	0.002	1	Manager.MapManager.getHeightByCoord
							0.048	0.000	1	Manager.MapManager.isOutOfMapByCoord
					0.097	0.003	1	kunpo.Components.Height.getHeight
						0.929	0.003	1	kunpo.Components.Height.getFlyHeight
							0.000	0.000	1	kunpo.Components.Buff.getAttribute
					0.007	0.000	1	kunpo.Components.Buff.getAttribute
					0.007	0.000	1	kunpo.Components.LimitMove.setNeedExtrusion
				0.054	0.020	11	kunpo.Components.Transformation.setPosition
					0.544	0.011	11	kunpo.Components.Collide.setPositionAndDir
					0.150	0.003	11	kunpo.Components.Transformation.getDirection
					0.050	0.001	11	kunpo.Components.Transformation.getPosition
				0.043	0.015	11	kunpo.Components.Movement.getMoveSpeed
					0.355	0.005	11	kunpo.Components.Movement.getTemporarySpeedChange
					0.184	0.003	11	kunpo.Components.Buff.getAttribute
				0.016	0.006	11	kunpo.Components.Movement.clearReactionForceList
				0.002	0.001	11	kunpo.Components.Transformation.getPosition
				0.002	0.001	11	kunpo.Components.Buff.getAttribute
				0.002	0.001	11	kunpo.Components.Movement.updateTemporarySpeedChanges
			0.164	0.154	1	kunpo.Components.Health.hurt
				0.998	0.154	1	kunpo.Components.Health.reduceHp
					0.003	0.000	1	kunpo.Components.DamageReduction.getDamageReduction
					0.002	0.000	1	kunpo.Components.Health.callChangeFuncs
					0.001	0.000	1	kunpo.Components.DamageReduction.getDamageReductionPercentage
			0.058	0.055	73	kunpo.Components.EffectContainer.update
				0.132	0.007	12	kunpo.Components.Transformation.getPosition
			0.040	0.038	1	kunpo.Components.EnemyRangeDamage.update
				0.679	0.026	1	Manager.ObjectManager.damageInRange
					0.485	0.013	1	Manager.MapManager.damageWallInRange
						0.379	0.005	6	kunpo.map.BarrierLayer.getBarrierByCoord
					0.343	0.009	1	Manager.ObjectManager.getObjectsInRange
						0.049	0.000	1	kunpo.Components.Collide.getPhysicPosition
							0.000	0.000	1	kunpo.Components.Transformation.getPosition
						0.012	0.000	1	Manager.ObjectManager.getInstance
						0.012	0.000	1	Manager.ObjectManager.getPlayers
						0.000	0.000	1	kunpo.Components.Collide.getPhysicRadius
					0.004	0.000	1	Manager.MapManager.getInstance
				0.099	0.004	1	kunpo.Components.Height.getHeight
					0.914	0.003	1	kunpo.Components.Height.getFlyHeight
						0.062	0.000	1	kunpo.Components.Buff.getAttribute
				0.014	0.001	1	kunpo.Components.Collide.getPhysicPosition
					0.400	0.000	1	kunpo.Components.Transformation.getPosition
				0.006	0.000	1	kunpo.Components.Collide.getPhysicRadius
				0.003	0.000	1	Manager.ObjectManager.getInstance
			0.034	0.032	11	kunpo.Components.AutoZOrder.update
				0.652	0.021	11	kunpo.Components.Height.getHeight
					0.534	0.011	11	kunpo.Components.Height.getFlyHeight
						0.382	0.004	11	kunpo.Components.Buff.getAttribute
				0.024	0.001	11	kunpo.Components.Transformation.getPosition
				0.024	0.001	11	Manager.MapManager.getMapSizeInPixel
			0.028	0.026	12	kunpo.Components.DistanceWithNearPlay.update
				0.131	0.003	11	kunpo.Components.DistanceWithNearPlay.setDistanceWithNearPlayerSQ
				0.123	0.003	11	Manager.ObjectManager.getNearPlayer
				0.123	0.003	22	kunpo.Components.Transformation.getPosition
				0.102	0.003	11	kunpo.Components.DistanceWithNearPlay.setNearPlayer
				0.029	0.001	11	Manager.ObjectManager.getInstance
			0.027	0.025	11	kunpo.Components.Shadow.update
				0.026	0.001	11	kunpo.Components.Transformation.getPosition
				0.022	0.001	11	kunpo.Components.Transformation.getHeight
			0.026	0.024	11	kunpo.Components.Buff.update
				0.422	0.010	11	Manager.BuffManager.postUpdate
					0.064	0.001	11	Manager.BuffManager.getBuffComponent
				0.126	0.003	11	Manager.BuffManager.perUpdate
				0.018	0.000	11	Manager.BuffManager.update
			0.018	0.017	12	kunpo.Components.RootNode.update
				0.065	0.001	12	kunpo.Components.Transformation.getScale
				0.039	0.001	12	kunpo.Components.Transformation.getPosition
				0.006	0.000	1	kunpo.Components.Transformation.getDirectionDegree
			0.014	0.013	11	kunpo.Components.Health.update
				0.269	0.003	11	kunpo.Components.Health.updateAttackSource
				0.235	0.003	11	kunpo.Components.Health.updateInvincible
			0.011	0.010	2	kunpo.Components.Surface.update
				0.874	0.009	2	kunpo.map.SurfaceLayer.getTypeByPosition
					0.349	0.003	2	Manager.MapManager.getCoordByPosition
					0.024	0.000	2	kunpo.map.SurfaceLayer.getTypeByCoord
					0.012	0.000	2	Manager.MapManager.getInstance
				0.000	0.000	2	kunpo.Components.Transformation.getPosition
				0.000	0.000	2	kunpo.Components.Surface.isValid
			0.011	0.010	2	kunpo.Components.AutoAdjustOrientation.update
				0.284	0.003	2	kunpo.CommonsLogics.getNearPlayer
					0.037	0.000	2	kunpo.Components.DistanceWithNearPlay.getNearPlayer
				0.021	0.000	2	kunpo.Components.Transformation.getScale
				0.021	0.000	4	kunpo.Components.Transformation.getPosition
				0.011	0.000	2	kunpo.Components.MessagePack.haveMessage
				0.011	0.000	2	kunpo.Components.RootNode.getRootNode
			0.010	0.010	10	kunpo.Components.Animation.update
				0.068	0.001	10	kunpo.Components.Transformation.getHeight
				0.045	0.000	9	kunpo.Components.Buff.getAttribute
			0.009	0.009	1	kunpo.Components.WeaponLocalZOrderUpdate.update
				0.402	0.004	1	kunpo.Components.SkillBase.update
					0.030	0.000	1	kunpo.Components.SkillBase.getSkillCd
				0.012	0.000	1	kunpo.Components.Transformation.getDirection
				0.012	0.000	1	kunpo.Components.SkillBase.getDestroyMe
			0.009	0.009	1	kunpo.Components.Streak.update
				0.025	0.000	4	kunpo.Components.Transformation.getPosition
				0.000	0.000	1	kunpo.Components.Movement.getSpeed
			0.009	0.008	3	kunpo.CommonsLogics.getCustomKey
			0.008	0.007	8	kunpo.Components.BTFullFrame.update
				0.060	0.000	8	kunpo.Components.Buff.getAttribute
			0.004	0.004	1	kunpo.map.BarrierLayer.getBarrierByPosition
				0.162	0.001	1	Manager.MapManager.getCoordByPosition
				0.054	0.000	1	Manager.MapManager.getInstance
				0.027	0.000	1	kunpo.map.BarrierLayer.getBarrierByCoord
			0.004	0.004	1	kunpo.Components.WeaponLogic.updateHolderDead
				0.057	0.000	1	kunpo.Components.StateMachine.getCurrentStateId
			0.004	0.004	12	kunpo.Components.FullFrameLogicalHosting.update
			0.003	0.003	7	kunpo.Components.MessagePack.haveMessage
			0.003	0.003	1	kunpo.CommonsLogics.getNearPlayer
				0.037	0.000	1	kunpo.Components.DistanceWithNearPlay.getNearPlayer
			0.003	0.003	1	Manager.MapManager.getBarrierLayer
			0.003	0.002	2	kunpo.Components.LogicalHosting.update
			0.002	0.002	1	Manager.ObjectManager.getInstance
			0.002	0.002	1	kunpo.Components.Transformation.setPosition
			0.002	0.002	1	kunpo.Components.Transformation.getDirection
			0.001	0.001	1	kunpo.Components.TailSmog.update
				0.000	0.000	1	kunpo.Components.Movement.getSpeed
			0.001	0.001	1	kunpo.Components.WeaponLogic.isAmmoEnough
				0.400	0.000	1	kunpo.Components.Ammunition.getAmmunition
			0.001	0.001	1	kunpo.Components.Animation.setTimeScale
			0.000	0.000	2	kunpo.Components.MessagePack.update
			0.000	0.000	1	kunpo.Components.MessagePack.removeMessage
			0.000	0.000	1	kunpo.Components.StateList.update
			0.000	0.000	1	kunpo.Components.WeaponLogic.getSuspendFire
			0.000	0.000	1	kunpo.Components.Movement.setSpeedDirection
			0.000	0.000	1	kunpo.Components.Animation.playAnimation
			0.000	0.000	3	kunpo.Components.Transformation.getPosition
			0.000	0.000	1	kunpo.Components.MessagePack.getLastMessage
			0.000	0.000	2	kunpo.Components.WeaponLogic.getIsFiring
			0.000	0.000	1	kunpo.Components.BTFullFrame.removeBTNode
			0.000	0.000	1	kunpo.Components.Transformation.setDirection
			0.000	0.000	1	kunpo.Components.Health.getIsDead
			0.000	0.000	2	kunpo.Components.Buff.getAttribute
			0.000	0.000	1	kunpo.Components.Transformation.getScale
			0.000	0.000	1	Manager.ObjectManager.getPlayerCount
			0.000	0.000	1	kunpo.Components.LimitMove.getLimitType
			0.000	0.000	1	Manager.MapManager.getInstance
		0.002	0.002	8	kunpo.Enemy.getIgnore
	0.011	0.011	1	Manager.ObjectManager.postUpdate
		0.673	0.007	1	Manager.UpdateManager.updateDestroy
	0.003	0.003	6	Manager.ObjectManager.getInstance
	0.002	0.002	2	Manager.ObjectManager.getWorld
	0.001	0.001	12	kunpo.Components.Transformation.getPosition
	0.001	0.001	1	kunpo.Components.DistanceWithNearPlay.updateSee
		0.200	0.000	1	kunpo.Components.DistanceWithNearPlay.update
	0.001	0.001	1	Manager.ObjectManager.pushIndexToNext
		0.400	0.000	1	Manager.UpdateManager.pushIndexToNext
	0.000	0.000	1	kunpo.Components.MessagePack.update
	0.000	0.000	1	Manager.ObjectManager.preUpdate
	0.000	0.000	1	kunpo.Components.LogicalHosting.update
	0.000	0.000	1	Manager.TaskUIManager.getInstance
	0.000	0.000	1	Manager.MachineManager.getInstance
	0.000	0.000	1	kunpo.Components.FullFrameLogicalHosting.update
	0.000	0.000	1	Manager.MachineManager.update
	0.000	0.000	1	Manager.TaskUIManager.update


self._statistics_time 
0.99739950157116	0.0092049999999997	kunpo.Components.BattleState.RuningUpdate
0.95178242496468	0.0087839999999986	Manager.ObjectManager.update
0.94268068046373	0.0086999999999993	Manager.UpdateManager.update
0.35843536677871	0.0033080000000005	kunpo.Components.Movement.update
0.24813089175392	0.0022899999999968	kunpo.Components.LimitMove.limitMove
0.19915483801114	0.0018380000000047	Manager.MapManager.isValidMovement
0.15429624011271	0.0014240000000001	kunpo.Components.Health.hurt
0.15397117780915	0.0014210000000006	kunpo.Components.Health.reduceHp
0.067721313251264	0.00062499999999588	Manager.MapManager.getTileInRect
0.054935529309863	0.0005070000000007	kunpo.Components.EffectContainer.update
0.044316827392243	0.00040900000000299	kunpo.Components.Height.getHeight
0.044208473290929	0.00040800000000196	Manager.MapManager.getCoordByPosition
0.038357351826511	0.00035400000000685	Manager.MapManager.getHeightByCoord
0.038140643623498	0.00035200000000124	kunpo.Components.EnemyRangeDamage.update
0.031747751652701	0.00029300000000276	kunpo.Components.AutoZOrder.update
0.031205981146131	0.00028799999999762	kunpo.Components.LimitMove.relieveLimit
0.030339148336965	0.00028000000000183	kunpo.Components.Height.getFlyHeight
0.026546754794628	0.00024499999999961	kunpo.Components.DistanceWithNearPlay.update
0.025896630187321	0.00023899999999877	Manager.ObjectManager.damageInRange
0.025138151479084	0.00023200000000045	kunpo.Components.Shadow.update
0.024162964567834	0.00022299999999653	kunpo.Components.Buff.update
0.021454112038061	0.00019799999999925	kunpo.Components.Transformation.setPosition
0.020695633328862	0.00019099999999206	kunpo.Components.Transformation.getPosition
0.016686531585244	0.00015400000000021	kunpo.Components.RootNode.update
0.015277928269508	0.00014099999999928	kunpo.Components.Movement.getMoveSpeed
0.014736157763707	0.00013600000000125	kunpo.Components.MessagePack.addMessage
0.013977679054701	0.00012899999999583	kunpo.Components.Buff.getAttribute
0.013327554448548	0.00012300000000565	Manager.MapManager.isValidMovementByHeight
0.012894138043099	0.00011899999999976	kunpo.Components.Health.update
0.01278578394217	0.00011800000000228	Manager.MapManager.isOutOfMap
0.012569075739542	0.00011600000000023	Manager.MapManager.damageWallInRange
0.011593888829255	0.00010700000000519	kunpo.Components.Collide.isFloating
0.010618701917813	9.7999999999487e-05	Manager.ObjectManager.postUpdate
0.010618701917813	9.7999999999487e-05	kunpo.Components.Collide.setPositionAndDir
0.010293639614255	9.4999999999956e-05	kunpo.Components.Surface.update
0.010293639614063	9.499999999818e-05	kunpo.Components.AutoAdjustOrientation.update
0.010185285512941	9.3999999998928e-05	Manager.BuffManager.postUpdate
0.010076931411819	9.2999999999677e-05	Manager.MapManager.isOutOfMapByCoord
0.0095351609058263	8.7999999999866e-05	kunpo.Components.Animation.update
0.0089933903998331	8.3000000000055e-05	kunpo.map.SurfaceLayer.getTypeByPosition
0.0088850362987115	8.2000000000804e-05	kunpo.Components.WeaponLocalZOrderUpdate.update
0.0088850362987115	8.2000000000804e-05	Manager.ObjectManager.getObjectsInRange
0.0087766821973974	8.0999999999776e-05	kunpo.Components.Streak.update
0.0082349116915967	7.6000000001741e-05	kunpo.CommonsLogics.getCustomKey
0.0072597247805395	6.6999999999595e-05	kunpo.Components.BTFullFrame.update
0.0071513706794178	6.6000000000344e-05	Manager.UpdateManager.updateDestroy
0.0062845378694823	5.7999999997449e-05	kunpo.Components.Movement.addExtraForce
0.0059594755661174	5.4999999999694e-05	Manager.ObjectManager.getInstance
0.0058511214649957	5.4000000000443e-05	kunpo.CommonsLogics.getNearPlayer
0.0056344132623675	5.1999999998387e-05	kunpo.Components.Movement.clearReactionForceList
0.0054177050601242	4.9999999999883e-05	Manager.MapManager.getHeightByPosition
0.0054177050601242	4.9999999999883e-05	kunpo.Components.Movement.getTemporarySpeedChange
0.0049842886550602	4.5999999997548e-05	kunpo.Components.Transformation.getDirection
0.0048759345543235	4.5000000001849e-05	kunpo.map.BarrierLayer.getBarrierByCoord
0.0047675804528169	4.3999999999045e-05	kunpo.Components.MessagePack.sortMessages
0.004009101744388	3.6999999998955e-05	kunpo.map.BarrierLayer.getBarrierByPosition
0.0037923935421447	3.5000000000451e-05	kunpo.Components.WeaponLogic.updateHolderDead
0.0036840394408306	3.3999999999423e-05	kunpo.Components.FullFrameLogicalHosting.update
0.0035756853397089	3.3000000000172e-05	kunpo.Components.SkillBase.update
0.0034673312382023	3.1999999997367e-05	kunpo.Components.DistanceWithNearPlay.setDistanceWithNearPlayerSQ
0.0034673312382023	3.1999999997367e-05	kunpo.Components.Health.updateAttackSource
0.0033589771374656	3.1000000001669e-05	kunpo.Components.MessagePack.haveMessage
0.0032506230361515	3.0000000000641e-05	Manager.ObjectManager.getNearPlayer
0.0031422689350299	2.9000000001389e-05	kunpo.Components.Collide.getCollide
0.0030339148339082	2.8000000002137e-05	Manager.BuffManager.perUpdate
0.0030339148335233	2.7999999998585e-05	kunpo.Components.Health.updateInvincible
0.0027088525301583	2.500000000083e-05	Manager.MapManager.getBarrierLayer
0.0027088525299659	2.4999999999054e-05	kunpo.Components.DistanceWithNearPlay.setNearPlayer
0.0026004984286517	2.3999999998026e-05	kunpo.Components.LogicalHosting.update
0.0023837902266009	2.2000000001299e-05	Manager.ObjectManager.getWorld
0.0022754361252868	2.1000000000271e-05	kunpo.Enemy.getIgnore
0.0014086033155438	1.2999999999153e-05	kunpo.Components.Transformation.getScale
0.0011918951129155	1.0999999997097e-05	kunpo.Components.Transformation.getHeight
0.0009751869108647	9.0000000003698e-06	kunpo.Components.Collide.getPhysicPosition
0.00086683280974306	8.0000000011182e-06	kunpo.Components.MessagePack.removeMessage
0.00075847870823646	6.9999999983139e-06	Manager.MapManager.getMapSizeInPixel
0.00065012460730729	6.0000000008387e-06	kunpo.Components.MessagePack.addMessageeOnly
0.00065012460711482	5.9999999990623e-06	Manager.BuffManager.getBuffComponent
0.00054177050618565	5.0000000015871e-06	kunpo.Components.Movement.getExtraForce
0.00054177050618565	5.0000000015871e-06	kunpo.Components.MessagePack.update
0.00054177050599317	4.9999999998107e-06	kunpo.Components.Animation.setTimeScale
0.00054177050599317	4.9999999998107e-06	kunpo.Components.DistanceWithNearPlay.updateSee
0.00054177050599317	4.9999999998107e-06	kunpo.Components.Movement.updateTemporarySpeedChanges
0.00054177050599317	4.9999999998107e-06	Manager.ObjectManager.pushIndexToNext
0.00054177050599317	4.9999999998107e-06	kunpo.Components.WeaponLogic.isAmmoEnough
0.00054177050599317	4.9999999998107e-06	kunpo.Components.TailSmog.update
0.00043341640487153	4.0000000005591e-06	Manager.MapManager.getInstance
0.00043341640487153	4.0000000005591e-06	kunpo.Components.DamageReduction.getDamageReduction
0.00043341640467905	3.9999999987828e-06	Manager.BuffManager.update
0.00032506230355741	2.9999999995312e-06	kunpo.Components.Health.callChangeFuncs
0.00021670820243576	2.0000000002796e-06	kunpo.Components.Animation.playAnimation
0.00021670820243576	2.0000000002796e-06	kunpo.Components.WeaponLogic.getSuspendFire
0.00021670820243576	2.0000000002796e-06	kunpo.Components.LimitMove.setNeedExtrusion
0.00021670820243576	2.0000000002796e-06	kunpo.Components.WeaponLogic.getIsFiring
0.00021670820243576	2.0000000002796e-06	kunpo.Components.Movement.setSpeedDirection
0.00021670820243576	2.0000000002796e-06	kunpo.Components.StateList.update
0.00021670820243576	2.0000000002796e-06	kunpo.Components.Ammunition.getAmmunition
0.00021670820243576	2.0000000002796e-06	kunpo.Components.MessagePack.getLastMessage
0.00021670820243576	2.0000000002796e-06	kunpo.Components.StateMachine.getCurrentStateId
0.00021670820243576	2.0000000002796e-06	kunpo.Components.DistanceWithNearPlay.getNearPlayer
0.00021670820243576	2.0000000002796e-06	kunpo.Components.Collide.getPhysicRadius
0.00021670820224329	1.9999999985032e-06	kunpo.Components.BTFullFrame.removeBTNode
0.00021670820224329	1.9999999985032e-06	Manager.UpdateManager.pushIndexToNext
0.00021670820224329	1.9999999985032e-06	kunpo.Components.MessagePack.regetSleepTo
0.00021670820224329	1.9999999985032e-06	kunpo.map.SurfaceLayer.getTypeByCoord
0.00021670820224329	1.9999999985032e-06	Manager.ObjectManager.preUpdate
0.00010835410131412	1.000000001028e-06	kunpo.Components.Transformation.setDirection
0.00010835410131412	1.000000001028e-06	kunpo.Components.Transformation.getDirectionDegree
0.00010835410131412	1.000000001028e-06	kunpo.Components.DamageReduction.getDamageReductionPercentage
0.00010835410131412	1.000000001028e-06	kunpo.Components.Health.getIsDead
0.00010835410112164	9.999999992516e-07	Manager.MachineManager.getInstance
0.00010835410112164	9.999999992516e-07	kunpo.Components.RootNode.getRootNode
0.00010835410112164	9.999999992516e-07	Manager.ObjectManager.getPlayers
0.00010835410112164	9.999999992516e-07	kunpo.Components.LimitMove.getLimitType
0.00010835410112164	9.999999992516e-07	Manager.ObjectManager.getPlayerCount
0.00010835410112164	9.999999992516e-07	kunpo.Components.SkillBase.getSkillCd
0.00010835410112164	9.999999992516e-07	kunpo.Components.SkillBase.getDestroyMe
0.00010835410112164	9.999999992516e-07	Manager.TaskUIManager.getInstance
0	0	kunpo.Components.Surface.isValid
0	0	kunpo.Components.Movement.getSpeed
0	0	Manager.MachineManager.update
0	0	Manager.TaskUIManager.update

self._statistics_count 
128	kunpo.Components.Transformation.getPosition
95	kunpo.Components.Buff.getAttribute
80	Manager.MapManager.getHeightByCoord
80	Manager.MapManager.isOutOfMapByCoord
79	Manager.MapManager.isValidMovementByHeight
73	kunpo.Components.EffectContainer.update
34	Manager.MapManager.getCoordByPosition
27	kunpo.Components.Height.getFlyHeight
27	kunpo.Components.Height.getHeight
21	kunpo.Components.Transformation.getHeight
20	Manager.ObjectManager.getInstance
15	Manager.MapManager.getTileInRect
15	kunpo.Components.Collide.getCollide
15	kunpo.Components.Transformation.getScale
15	Manager.MapManager.isValidMovement
15	kunpo.Components.Collide.isFloating
15	Manager.MapManager.isOutOfMap
13	kunpo.Components.FullFrameLogicalHosting.update
13	kunpo.Components.Transformation.getDirection
13	kunpo.Components.DistanceWithNearPlay.update
12	kunpo.Components.Transformation.setPosition
12	kunpo.Components.RootNode.update
11	kunpo.Components.Health.updateInvincible
11	kunpo.Components.LimitMove.relieveLimit
11	kunpo.Components.AutoZOrder.update
11	Manager.BuffManager.update
11	kunpo.Components.LimitMove.limitMove
11	kunpo.Components.Movement.updateTemporarySpeedChanges
11	kunpo.Components.Buff.update
11	Manager.BuffManager.postUpdate
11	kunpo.Components.Movement.getTemporarySpeedChange
11	Manager.MapManager.getMapSizeInPixel
11	Manager.BuffManager.getBuffComponent
11	kunpo.Components.Shadow.update
11	kunpo.Components.DistanceWithNearPlay.setNearPlayer
11	kunpo.Components.DistanceWithNearPlay.setDistanceWithNearPlayerSQ
11	kunpo.Components.Movement.update
11	kunpo.Components.Movement.getMoveSpeed
11	kunpo.Components.Health.updateAttackSource
11	Manager.BuffManager.perUpdate
11	kunpo.Components.Collide.setPositionAndDir
11	kunpo.Components.Movement.clearReactionForceList
11	Manager.ObjectManager.getNearPlayer
11	kunpo.Components.Health.update
10	kunpo.Components.Animation.update
9	kunpo.Components.MessagePack.haveMessage
8	kunpo.Enemy.getIgnore
8	kunpo.Components.BTFullFrame.update
7	kunpo.map.BarrierLayer.getBarrierByCoord
5	kunpo.Components.MessagePack.removeMessage
5	Manager.MapManager.getInstance
5	kunpo.Components.Movement.getExtraForce
4	kunpo.Components.MessagePack.sortMessages
4	kunpo.Components.MessagePack.addMessageeOnly
4	kunpo.Components.MessagePack.addMessage
4	kunpo.Components.Movement.addExtraForce
4	kunpo.Components.MessagePack.regetSleepTo
3	kunpo.Components.LogicalHosting.update
3	kunpo.Components.DistanceWithNearPlay.getNearPlayer
3	kunpo.Components.MessagePack.update
3	kunpo.CommonsLogics.getCustomKey
3	kunpo.CommonsLogics.getNearPlayer
2	kunpo.Components.RootNode.getRootNode
2	kunpo.Components.Surface.update
2	kunpo.Components.AutoAdjustOrientation.update
2	kunpo.Components.WeaponLogic.getIsFiring
2	kunpo.Components.Movement.getSpeed
2	kunpo.map.SurfaceLayer.getTypeByCoord
2	kunpo.Components.Surface.isValid
2	kunpo.Components.Collide.getPhysicRadius
2	Manager.ObjectManager.getWorld
2	kunpo.Components.Collide.getPhysicPosition
2	kunpo.Components.LimitMove.setNeedExtrusion
2	kunpo.map.SurfaceLayer.getTypeByPosition
1	kunpo.Components.BattleState.RuningUpdate
1	kunpo.Components.Movement.setSpeedDirection
1	kunpo.Components.Ammunition.getAmmunition
1	kunpo.Components.MessagePack.getLastMessage
1	kunpo.Components.Animation.playAnimation
1	kunpo.Components.Health.getIsDead
1	Manager.ObjectManager.postUpdate
1	kunpo.Components.TailSmog.update
1	Manager.TaskUIManager.getInstance
1	Manager.TaskUIManager.update
1	Manager.UpdateManager.pushIndexToNext
1	kunpo.Components.Transformation.getDirectionDegree
1	kunpo.Components.DamageReduction.getDamageReduction
1	kunpo.Components.WeaponLogic.updateHolderDead
1	kunpo.Components.StateList.update
1	kunpo.Components.BTFullFrame.removeBTNode
1	Manager.MachineManager.update
1	Manager.MapManager.getHeightByPosition
1	kunpo.Components.EnemyRangeDamage.update
1	kunpo.Components.WeaponLogic.isAmmoEnough
1	kunpo.Components.SkillBase.getDestroyMe
1	Manager.MapManager.damageWallInRange
1	Manager.MachineManager.getInstance
1	kunpo.Components.DamageReduction.getDamageReductionPercentage
1	kunpo.Components.StateMachine.getCurrentStateId
1	kunpo.Components.SkillBase.update
1	kunpo.Components.WeaponLocalZOrderUpdate.update
1	kunpo.Components.Animation.setTimeScale
1	kunpo.Components.Health.reduceHp
1	kunpo.Components.Transformation.setDirection
1	kunpo.Components.DistanceWithNearPlay.updateSee
1	kunpo.Components.Health.hurt
1	Manager.ObjectManager.update
1	kunpo.Components.SkillBase.getSkillCd
1	Manager.MapManager.getBarrierLayer
1	kunpo.Components.Streak.update
1	kunpo.Components.LimitMove.getLimitType
1	Manager.ObjectManager.pushIndexToNext
1	Manager.ObjectManager.getPlayers
1	Manager.ObjectManager.getPlayerCount
1	kunpo.map.BarrierLayer.getBarrierByPosition
1	Manager.ObjectManager.getObjectsInRange
1	Manager.ObjectManager.damageInRange
1	Manager.UpdateManager.updateDestroy
1	kunpo.Components.Health.callChangeFuncs
1	kunpo.Components.WeaponLogic.getSuspendFire
1	Manager.UpdateManager.update
1	Manager.ObjectManager.preUpdate


この情報は3つのセグメントに分かれています.
  • 第1セグメントは呼び出しのツリー型出力であり、それらの間の呼び出し関係を知ることができる.各関数は親ノードの時間スケールを占有し、総時間の時間スケール、呼び出し回数、関数名
  • を占有する.
  • 第2段階は、関数呼び出しの合計時間の長さの割合である.関数が長すぎる場合.彼が呼び出された回数が多いか、彼の実現比較ゴミ
  • 第3段階は、関数呼び出し回数の合計ソートである.1つの関数の呼び出し回数が多い場合は、この関数の呼び出し回数を減らすことが考えられます.方法は自分で考えることができる.

  • ああ、木の構造の実現も忘れた
    local TreeNode = class("TreeNode")
    
    function TreeNode:ctor()
    	self._parent = nil
    	self._childs = {}
    	self._name = nil
    	self._data = nil
    end
    
    function TreeNode:setName(v)
    	self._name = v
    end
    
    function TreeNode:getName()
    	return self._name
    end
    
    function TreeNode:setParent(v)
    	self._parent = v
    end
    
    function TreeNode:getParent()
    	return self._parent
    end
    
    function TreeNode:addChild(v)
    	table.insert(self._childs, v)
    end
    
    function TreeNode:getChilds()
    	return self._childs
    end
    
    function TreeNode:getChildByName(name)
    	local data = nil
    
    	for _, item in ipairs(self._childs) do
    		if item:getName() == name then
    			data = item
    			break
    		end
    	end
    
    	return data
    end
    
    function TreeNode:clearChilds()
    	self._childs = {}
    end
    
    function TreeNode:setData(v)
    	self._data = v
    end
    
    function TreeNode:getData()
    	return self._data
    end
    
    kunpo.TreeNode = TreeNode
    
    return TreeNode
    

    これは簡単ですから、言わないでください.
    最後に本当に申し訳ありませんが、後で考えます.私はまだ仕方がない.この問題がどのように解決されるかをスムーズに説明します.書くレベルは本当に限られているので、間に合って見ましょう.