您的位置:首页 > 编程语言 > Python开发

Using Python to show the test data

2017-03-15 16:54 363 查看
#!/usr/bin/python
#coding:utf-8

import os
import string
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

decode_time_list=[]
swap_time_list=[]
updateTexture_time_list=[]

def drawBar(arr, des):
X=range(len(arr))
Y=arr
fig = plt.figure()
plt.bar(X,Y,0.5,color="green",align='center')
plt.xlabel(des + " frame count")
y_str = des + " time consuming (ms)";
plt.ylabel(y_str)
plt.title(y_str)
plt.show()

def process(filename):
file = open(filename,"r")
for eachline in file.readlines():
index0 = eachline.find('avcodec_decode_video2')
index1 = eachline.find('SDL_RenderPresent')
index2 = eachline.find('SDL_UpdateTexture')
if index0 != -1:
str = eachline.split("[")[1].split("]")[0]
time = int(str)
decode_time_list.append(time)
print "decode: %s ms" %str
elif index1 != -1:
str = eachline.split("[")[1].split("]")[0]
time = int(str)
swap_time_list.append(time)
print "swap : %s ms" %str
elif index2 != -1:
str = eachline.split("[")[1].split("]")[0]
time = int(str)
updateTexture_time_list.append(time)
print "draw : %s ms" %str

print "decoding frame count: %d" %(len(decode_time_list))

if __name__ == "__main__":
fn = "1.log.test"
process(fn)
drawBar(decode_time_list, "decoding");
drawBar(swap_time_list, "swap buffer");
drawBar(updateTexture_time_list, "update texture");



Python to show the test output data
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐