1 #!/usr/bin/env python 2 # SPDX-License-Identifier: Apache-2.0 3 # 4 # Copyright (C) 2017, ARM Limited, Google, and contributors. 5 # 6 # Licensed under the Apache License, Version 2.0 (the "License"); you may 7 # not use this file except in compliance with the License. 8 # You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, software 13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 # See the License for the specific language governing permissions and 16 # limitations under the License. 17 # 18 19 import logging 20 21 from conf import LisaLogging 22 LisaLogging.setup() 23 import json 24 import os 25 import devlib 26 from env import TestEnv 27 from android import Screen, Workload, System 28 from trace import Trace 29 import trappy 30 import pandas as pd 31 import sqlite3 32 import argparse 33 import shutil 34 35 parser = argparse.ArgumentParser(description='CameraFlashlight') 36 37 parser.add_argument('--out_prefix', dest='out_prefix', action='store', default='default', 38 help='prefix for out directory') 39 40 parser.add_argument('--collect', dest='collect', action='store', default='energy', 41 help='what to collect (default energy)') 42 43 parser.add_argument('--duration', dest='duration_s', action='store', 44 default=30, type=int, 45 help='Duration of test (default 30s)') 46 47 parser.add_argument('--serial', dest='serial', action='store', 48 help='Serial number of device to test') 49 50 args = parser.parse_args() 51 52 def experiment(): 53 # Get workload 54 wload = Workload.getInstance(te, 'AppStartup') 55 56 outdir=te.res_dir + '_' + args.out_prefix 57 try: 58 shutil.rmtree(outdir) 59 except: 60 print "couldn't remove " + outdir 61 pass 62 os.makedirs(outdir) 63 64 package = 'com.example.android.powerprofile.cameraflashlight' 65 permissions = [] 66 67 # Set airplane mode 68 System.set_airplane_mode(target, on=True) 69 70 # Run AppStartup workload with the flashlight app 71 wload.run(outdir, package=package, permissions=permissions, 72 duration_s=args.duration_s, collect=args.collect) 73 74 # Turn off airplane mode 75 System.set_airplane_mode(target, on=False) 76 77 # Dump platform descriptor 78 te.platform_dump(te.res_dir) 79 80 te._log.info('RESULTS are in out directory: {}'.format(outdir)) 81 82 # Setup target configuration 83 my_conf = { 84 85 # Target platform and board 86 "platform" : 'android', 87 88 # Useful for reading names of little/big cluster 89 # and energy model info, its device specific and use 90 # only if needed for analysis 91 # "board" : 'pixel', 92 93 # Device 94 # By default the device connected is detected, but if more than 1 95 # device, override the following to get a specific device. 96 # "device" : "HT6880200489", 97 98 # Folder where all the results will be collected 99 "results_dir" : "CameraFlashlight", 100 101 # Define devlib modules to load 102 "modules" : [ 103 'cpufreq', # enable CPUFreq support 104 ], 105 106 "emeter" : { 107 'instrument': 'monsoon', 108 'conf': { } 109 }, 110 111 # Tools required by the experiments 112 "tools" : [], 113 } 114 115 if args.serial: 116 my_conf["device"] = args.serial 117 118 # Initialize a test environment using: 119 te = TestEnv(my_conf, wipe=False) 120 target = te.target 121 122 results = experiment() 123