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