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