前端之家收集整理的这篇文章主要介绍了
cocos统计内存的 py 脚本,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
import re,datetime
def action():
file_name = '/Users/jiangxf/Desktop/funstone/log2.txt'
file = open(file_name,'r')
data = {}
a = 0
for (num,line) in enumerate(file):
m = re.search(r'^.*\/(.*)\..* (.*) KB$',line)
if m:
b = m.group(2)
if b:
a += int(b)
data[m.group(1)] = int(b)
a = a / 1024
print (a," MB")
data = sorted(data.items(),key = lambda x: x[1],reverse = True)
for k,v in enumerate(data):
print k,v
file.close()
if __name__ == '__main__':
action()
local s =cc.Director:getInstance():getTextureCache():getCachedTextureInfo()
print(s)
local path_ = CCFileUtils:sharedFileUtils():getWritablePath().."/out.txt"
print(path_)
local f = io.open(path_,"w+")
f:write(s);
f:close();
原文链接:https://www.f2er.com/cocos2dx/338232.html