1 #!/usr/bin/env python 2 3 import logging 4 5 from conf import LisaLogging 6 LisaLogging.setup() 7 import json 8 import os 9 import devlib 10 from env import TestEnv 11 from android import Screen, Workload, System 12 from trace import Trace 13 import trappy 14 import pandas as pd 15 import sqlite3 16 import argparse 17 import shutil 18 19 workloads = ['CameraPreview', 'CameraStartup'] 20 21 parser = argparse.ArgumentParser(description='Camera Workload tests') 22 23 parser.add_argument('--out_prefix', dest='out_prefix', action='store', default='default', 24 help='prefix for out directory') 25 26 parser.add_argument('--collect', dest='collect', action='store', default='systrace', 27 help='what to collect (default systrace)') 28 29 parser.add_argument('--duration', dest='duration_s', action='store', 30 type=int, 31 help='Duration of test (default 30s)') 32 33 parser.add_argument('--serial', dest='serial', action='store', 34 help='Serial number of device to test') 35 36 parser.add_argument('--workload', dest='workload', action='store', 37 default='CameraPreview', help='Camera workload to run (ex. CameraPreview)') 38 39 args = parser.parse_args() 40 41 if args.workload not in workloads: 42 raise RuntimeError('Invalid workload specified') 43 44 def experiment(): 45 # Get workload 46 wload = Workload.getInstance(te, args.workload) 47 48 outdir=te.res_dir + '_' + args.out_prefix 49 try: 50 shutil.rmtree(outdir) 51 except: 52 print "coulnd't remove " + outdir 53 pass 54 os.makedirs(outdir) 55 56 # Run Camera 57 # Note: The default time duration of the test is specificified within the workload 58 if args.duration_s: 59 wload.run(outdir, duration_s=args.duration_s, collect=args.collect) 60 else: 61 wload.run(outdir, collect=args.collect) 62 63 # Dump platform descriptor 64 te.platform_dump(te.res_dir) 65 66 te._log.info('RESULTS are in out directory: {}'.format(outdir)) 67 68 # Setup target configuration 69 my_conf = { 70 71 # Target platform and board 72 "platform" : 'android', 73 74 # Useful for reading names of little/big cluster 75 # and energy model info, its device specific and use 76 # only if needed for analysis 77 # "board" : 'pixel', 78 79 # Device 80 # By default the device connected is detected, but if more than 1 81 # device, override the following to get a specific device. 82 # "device" : "HT6880200489", 83 84 # Folder where all the results will be collected 85 "results_dir" : args.workload, 86 87 # Define devlib modules to load 88 "modules" : [ 89 'cpufreq', # enable CPUFreq support 90 'cpuidle', # enable cpuidle support 91 # 'cgroups' # Enable for cgroup support 92 ], 93 94 "emeter" : { 95 'instrument': 'monsoon', 96 'conf': { } 97 }, 98 99 "systrace": { 100 'extra_categories': ['camera'] 101 }, 102 103 # Tools required by the experiments 104 "tools" : [ 'taskset'], 105 } 106 107 if args.serial: 108 my_conf["device"] = args.serial 109 110 # Initialize a test environment using: 111 te = TestEnv(my_conf, wipe=False) 112 target = te.target 113 114 results = experiment() 115