怎么调试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++层面上通过两个回调(函数进入时、退出时)然后统计时间,然后根据执行的先后顺序来一层一层的打印对应的对战,达到游戏中所有的函数运行时间心中有数的目的。因为没有找到他的源码。不过好在读懂他是什么意思了。不过我对于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

不过在添加的时候可能会加载不上,因为Cocos2dx-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").."\n") 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.."\n") -- 瀑布式打印
local alltime = PerformanceStatistics:getInstance()._all_time
for _, item in pairs(self._call_stack) do
WriteTreeToFile(item, alltime)
io.write("\n")
end -- 普通打印
io.write("\nself._statistics_time \n")
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") .. "\n")
end io.write("\nself._statistics_count \n")
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") .. "\n")
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

这段信息分成了三段:

  • 第一段是调用的树型输出,可以知道他们之间的调用关系。每个函数占用父节点的时间比例,占用总时间的时间比例、调用次数、函数名称
  • 第二阶段是总共的函数调用时长比例。如果某个函数调用的时间太长。要么就是他被调用的次数很多,要么就是他的实现比较垃圾
  • 第三阶段是总共的函数调用次数排序。如果某一个函数调用次数比较多,那么可以考虑减少这个函数的调用次数。方法可以自己想。

啊,还忘了树形结构的实现

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

这个很简单的,我就不说了。

最后真的抱歉,我回头想想。我还是没有办法。非常顺畅的描述这个问题怎么解决。写作水平真的有限,凑合看吧。

怎么调试lua性能的更多相关文章

  1. 如何调试lua脚本

    首先感谢下ZeroBrane Studio. 这里拿cocos2dx/samples/Lua/HelloLua做例子来说明,其他的都是同样道理. 1.下载调试Lua所需的IDE,地址在这.有经济实力的 ...

  2. 使用BabeLua在cocos2d-x中编辑和调试Lua

    使用BabeLua在cocos2d-x中编辑和调试Lua BabeLua是一款基于VS2012/2013的Lua集成开发环境,具有Lua语法高亮,语法检查.自己主动补全.高速搜索,注入宿主程序内对Lu ...

  3. NodeJS的代码调试和性能调优

    本文转自我的个人博客. NodeJS 自 2009 年显露人间,到现在已经六个年头了,由于各种原因,中间派生出了个兄弟,叫做 iojs,最近兄弟继续合体,衍生出了 nodejs4.0 版本,这东西算是 ...

  4. 快速学习C语言二: 编译自动化, 静态分析, 单元测试,coredump调试,性能剖析

    上次的Hello world算是入门了,现在学习一些相关工具的使用 编译自动化 写好程序,首先要编译,就用gcc就好了,基本用法如下 gcc helloworld.c -o helloworld.o ...

  5. ZeroBrane Studio远程调试Lua程序(转)

    环境: ZeroBrane Studio安装在Windows 7上,而要调试的程序运行在CentOS上: 设置: 在windows 7上,打开ZeroBrane Studio,打开需要调试的文件,例如 ...

  6. Lua性能优化

    原文:Lua Performance Tips 偶然找到<Lua Performance Tips>这篇关于Lua的优化文章,个人认为相较于多数泛泛而谈要好不少.尽管Lua已经到5.2版本 ...

  7. 工作流程,编程,调试,性能:Unity游戏开发者应该学习的20个改进技巧

    Unity 是一个备受欢迎的游戏开发平台.它的功能令人印象深刻,同时也迎合了不同的游戏开发需求.游戏开发者可以使用 Unity 创建任何类型的游戏,从世界级的 RPG 游戏到最流行的增强现实游戏 Po ...

  8. 使用BabeLua3.x在cocos2d-x中编辑和调试Lua

    BabeLua是一款基于VS2012/2013的Lua集成开发环境,具有Lua语法高亮,语法检查,自动补全,快速搜索,注入宿主程序内对Lua脚本进行调试,设置断点观察变量值,查看堆栈信息等功能. 如何 ...

  9. PHPStorm 初遇 Xdebug (xdebug代码调试及性能分析)

    centos 7 下PHP7安装xdebug # 下载xdebug wget https://xdebug.org/files/xdebug-2.7.2.tgz # 解压 tar -xf xdebug ...

随机推荐

  1. HTML文档头部

    前面的话   在声明文档类型之后,HTML文档的下一部分为<html>标签,告知浏览器应将括在<html>...</html>内的所有内容解析为HTML.然后是HT ...

  2. [.NET] 怎样使用 async & await 一步步将同步代码转换为异步编程

    怎样使用 async & await 一步步将同步代码转换为异步编程 [博主]反骨仔 [出处]http://www.cnblogs.com/liqingwen/p/6079707.html  ...

  3. MFC中成员变量的声明顺序与析构顺序

    第一次用博客,第一篇随笔,就写今天遇到的一个问题吧. 在VS2008的MFC对话框程序,窗口成员变量的声明顺序与其析构顺序相反,即,先声明的变量后析构,后声明的变量先析构.未在其他模式下测试. cla ...

  4. C语言可以开发哪些项目?

    C语言是我们大多数人的编程入门语言,对其也再熟悉不过了,不过很多初学者在学习的过程中难免会出现迷茫,比如:不知道C语言可以开发哪些项目,可以应用在哪些实际的开发中--,这些迷茫也导致了我们在学习的过程 ...

  5. NV显卡Ubuntu14.04更新软件导致登录死循环,不过可以进入tty模式

    注意:此方法只适用于nv显卡的电脑! 在网上寻找各种方法无果的情况下,选择重新安装显卡驱动,成功登录进入图形界面. 一.首先需要在另外一台电脑(windows系统也可以)上下载NVIDIA相应显卡驱动 ...

  6. Python处理Excel表格

    同事小王今天说他有一个Excel表格,表格如下,一列是姓名,一列是电话号码,总共有大概2000行数据. 有的姓名占了一行,有的占了两行,还有一些占了三行的.如下图: 他问我可不可以全部统一成一行,而且 ...

  7. Python3中的字符串函数学习总结

    这篇文章主要介绍了Python3中的字符串函数学习总结,本文讲解了格式化类方法.查找 & 替换类方法.拆分 & 组合类方法等内容,需要的朋友可以参考下. Sequence Types ...

  8. emmet,jade,haml, slim,less,sass,coffeescript等的实战优缺点

    摘要: 文章背景,来自于群内周五晚上的一次头脑风暴式的思维碰撞交流活动. 随着前端技术的蓬勃发展, 各种新技术随着生产力的需要不断的涌入我们的视野, 那今天探讨的话题是这些新时代的前端兵器谱: 一. ...

  9. 谨慎使用Marker Interface

    之所以写这篇文章,源自于组内的一些技术讨论.实际上,Effective Java的Item 37已经详细地讨论了Marker Interface.但是从整个Item的角度来看,其对于Marker In ...

  10. CSS3变形记(上):千变万化的Div

    传统上,css就是用来对网页进行布局和渲染网页样式的.然而,css3的出现彻底打破了这一格局.了解过css3的人都知道,css3不但可以对网页进行布局和渲染样式,还可以绘制一些图形.对元素进行2D和3 ...