shell脚本 ,test_95.sh
#!/bin/sh
# 3D显示性能测试
# 测试3D显示处理性能,主要包括3D的显示,
# 色彩填充,渲染,旋转等性能测试
test_title="3D显示性能测试 标识95"
expect_result="预期结果:能够3D图像显示、色彩填充、渲染、旋转,记录平均的FPS"
result_path=./
echo -e "\n" >> ${result_path}test_95_result.txt
date >> ${result_path}test_95_result.txt
echo ${test_title} >> ${result_path}test_95_result.txt
echo -e >> ${result_path}test_95_result.txt
echo ${expect_result} >> ${result_path}test_95_result.txt
#开始测试 下面带2的文件是要通过python处理的 这里的不需要追加
vblank_mode=0 glxgears > ${result_path}test_95_result2.txt
test_95.py
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#本文件只能和对应的sh文件独立启动,不能够在在shell脚本调用
import commands,os,subprocess
#处理3D性能所生成的FPS,进行平均
#处理行
f1 = open("test_95_result2.txt","r")
line_f1 = f1.readlines() #readlines()函数不能重复读
line_f1_1 = line_f1[0]
line_f1_2 = line_f1[1]
line_f1_3 = line_f1[2]
line_f1_4 = line_f1[3]
line_f1_5 = line_f1[4]
line_f1_6 = line_f1[5]
line_f1_7 = line_f1[6]
line_f1_8 = line_f1[7]
line_f1_9 = line_f1[8]
line_f1_10 = line_f1[9]
#处理列
line_f1_1_7 = line_f1_1.split()[6]
#print line_f1_1_7
line_f1_2_7 = line_f1_2.split()[6]
line_f1_3_7 = line_f1_3.split()[6]
line_f1_4_7 = line_f1_4.split()[6]
line_f1_5_7 = line_f1_5.split()[6]
line_f1_6_7 = line_f1_6.split()[6]
line_f1_7_7 = line_f1_7.split()[6]
line_f1_8_7 = line_f1_8.split()[6]
line_f1_9_7 = line_f1_9.split()[6]
line_f1_10_7 = line_f1_10.split()[6]
average = (float(line_f1_1_7) + float(line_f1_2_7) + float(line_f1_3_7) + float(line_f1_4_7) + float(line_f1_5_7) + float(line_f1_6_7) + float(line_f1_7_7) + float(line_f1_8_7) + float(line_f1_9_7) + float(line_f1_10_7)) / 10
f1.close()
print "average:"+ str(average) + "FPS"
fw1 = file("test_95_result.txt","a+")
fw1.write("\r\n average" + str(average) + " FPS\r\n")
fw1.close()
#结束glxgears进程
#寻找glxgears进程的进程id 不可追加
subprocess.call("ps -aux | grep glxgears > glxgears.txt",shell=True)
f2 = open("glxgears.txt","r")
line_f2 = f2.readlines()[0]
line_2_f2 = line_f2.split()[1]
print line_2_f2
f2.close()
subprocess.call("sleep 3",shell=True)
subprocess.call("kill -9 "+line_2_f2,shell=True)
subprocess.call("rm -rf glxgears.txt",shell=True)