“Draw”是指Java层用在创建“display lists”(显示列表)上的时间。它表明运行例如View.onDraw(Canvas)需要多少时间。
“Process”是指Android 2D渲染引擎用在执行“display lists”上的时间。你的UI层级(hierarchy)中的View数量越多,需要执行的绘画命令就越多。
“Execute”是指将一帧图像交给合成器(compositor)的时间。这部分占用的时间通常比较少
接下来我们要做的就是保存log到txt。
接着直接更改文件路径直接运行程序即可。可以看到如下的图表
python代码如下:
from urllib import urlopen
from reportlab.graphics.shapes import *
from reportlab.graphics.charts.lineplots import LinePlot
from reportlab.graphics.charts.textlabels import Label
from reportlab.graphics import renderPDF
name_infile = file('/Users/apple/Desktop/python/gfxinfo.txt', 'r')
char = []
drawing = Drawing(400,200)
data = []
times = []
for line in name_infile.readlines():
try:
char.append(line)
except IndexError,e:
print 'out of range'
for i in range(len(char)):
if 'Draw' in char[i][1:5]:
Begin_number = i
if 'View' in char[i][0:4]:
End_number = i
for i in range(Begin_number+1,End_number-1):
data.append([float(n) for n in char[i].split()])
print data
for i in range(len(data)):
times.append(i)
print times
Draw = [row[0] for row in data]
Process = [row[1] for row in data]
Execute = [row[2] for row in data]
lp = LinePlot()
lp.x = 50
lp.y = 50
lp.height = 125
lp.width = 300
lp.data = [zip(times, Draw),zip(times,Process),zip(times, Execute)]
lp.lines[0].strokeColor = colors.blue
lp.lines[1].strokeColor = colors.red
lp.lines[2].strokeColor = colors.green
drawing.add(lp)
drawing.add(String(250,150, 'ngxinfo',fontSize=14,fillColor=colors.red))
renderPDF.drawToFile(drawing, 'ngxinfo.pdf','ngxinfo