mirror of
https://github.com/ARM-software/workload-automation.git
synced 2024-10-06 19:01:15 +01:00
76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
# Copyright 2013-2015 ARM Limited
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
|
|
|
|
import os
|
|
import re
|
|
import time
|
|
|
|
from wlauto import AndroidBenchmark
|
|
from uiautomator import Device
|
|
|
|
|
|
class Androbench(AndroidBenchmark):
|
|
|
|
name = 'androbench'
|
|
description = """Androbench measures the storage performance of device"""
|
|
package = 'com.andromeda.androbench2'
|
|
activity = '.main'
|
|
device=''
|
|
|
|
def setup(self, context):
|
|
global device
|
|
os.system('adb devices > deviceinfo')
|
|
devinf = open('deviceinfo','rb')
|
|
dev = devinf.readlines()[1].split('\t')[0]
|
|
devinf.close()
|
|
device=Device(dev)
|
|
os.system('rm deviceinfo')
|
|
|
|
|
|
def run(self, context):
|
|
global device,package,activity
|
|
os.system('adb shell pm clear com.andromeda.androbench2')
|
|
os.system('adb shell am start -n com.andromeda.androbench2/.main')
|
|
while True :
|
|
if device(text="Measure your storage performance").exists :
|
|
time.sleep(1)
|
|
break
|
|
|
|
if device(textStartsWith="Micro").exists :
|
|
device(textStartsWith="Micro").click()
|
|
if device(text="Yes").exists :
|
|
device(textStartsWith="Yes").click()
|
|
|
|
|
|
while True :
|
|
if device(text="Cancel").exists :
|
|
device(text="Cancel").click()
|
|
time.sleep(1)
|
|
break
|
|
|
|
|
|
def update_result(self, context):
|
|
super(Androbench, self).update_result(context)
|
|
os.system('adb shell sqlite3 /data/data/com.andromeda.androbench2/databases/history.db "select * from history" > results.raw')
|
|
fhresults=open("results.raw","rb")
|
|
results=fhresults.readlines()[0].split('|')
|
|
context.result.add_metric('Sequential Read ', results[8], 'MB/s')
|
|
context.result.add_metric('Sequential Write MB/s ', results[9] , 'MB/s')
|
|
context.result.add_metric('Random Read MB/s ', results[10], 'MB/s')
|
|
context.result.add_metric('Random Write MB/s ', results[12], 'MB/s')
|
|
os.system('rm results.raw')
|
|
|