Home | History | Annotate | Download | only in experiments
      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 # Description: This experiments tests idle/resume by turning off
     36 # the screen and cutting off USB
     37 # REQUIRES DEVICE TO BE CONNECTED THROUGH MONSOON SO THAT PASSTHROUGH
     38 # CAN BE TURNED OFF. By default energy will be measured in this test.
     39 
     40 parser = argparse.ArgumentParser(description='IdleResume tests')
     41 
     42 parser.add_argument('--out_prefix', dest='out_prefix', action='store', default='default',
     43                     help='prefix for out directory')
     44 
     45 parser.add_argument('--collect', dest='collect', action='store', default='systrace',
     46                     help='what to collect (default systrace)')
     47 
     48 parser.add_argument('--duration', dest='duration_s', action='store',
     49                     default=15, type=int,
     50                     help='Duration of test (default 15s)')
     51 
     52 parser.add_argument('--serial', dest='serial', action='store',
     53                     help='Serial number of device to test')
     54 
     55 args = parser.parse_args()
     56 
     57 def experiment():
     58     # Get workload
     59     wload = Workload.getInstance(te, 'IdleResume')
     60 
     61     outdir=te.res_dir + '_' + args.out_prefix
     62     try:
     63         shutil.rmtree(outdir)
     64     except:
     65         print "couldn't remove " + outdir
     66         pass
     67     os.makedirs(outdir)
     68 
     69     # Run IdleResume
     70     wload.run(outdir, duration_s=args.duration_s, collect=args.collect)
     71 
     72     # Dump platform descriptor
     73     te.platform_dump(te.res_dir)
     74 
     75     te._log.info('RESULTS are in out directory: {}'.format(outdir))
     76 
     77 # Setup target configuration
     78 my_conf = {
     79 
     80     # Target platform and board
     81     "platform"     : 'android',
     82 
     83     # Useful for reading names of little/big cluster
     84     # and energy model info, its device specific and use
     85     # only if needed for analysis
     86     # "board"        : 'pixel',
     87 
     88     # Device
     89     # By default the device connected is detected, but if more than 1
     90     # device, override the following to get a specific device.
     91     # "device"       : "HT6880200489",
     92 
     93     # Folder where all the results will be collected
     94     "results_dir" : "IdleResume",
     95 
     96     # Define devlib modules to load
     97     "modules"     : [
     98         'cpufreq',      # enable CPUFreq support
     99         'cpuidle',      # enable cpuidle support
    100         # 'cgroups'     # Enable for cgroup support
    101     ],
    102 
    103     "emeter" : {
    104         'instrument': 'monsoon',
    105         'conf': { }
    106     },
    107 
    108     # Tools required by the experiments
    109     "tools"   : [ 'taskset'],
    110 
    111     "skip_nrg_model" : True,
    112 }
    113 
    114 if args.serial:
    115     my_conf["device"] = args.serial
    116 
    117 # Initialize a test environment using:
    118 te = TestEnv(my_conf, wipe=False)
    119 target = te.target
    120 
    121 results = experiment()
    122