1#!/bin/bash 2 3# Copyright (C) 2020 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17readme() { 18 echo ' 19Analyze boot-time & bootchart 20e.g. 21ANDROID_BUILD_TOP="$PWD" \ 22CONFIG_YMAL="$ANDROID_BUILD_TOP/system/extras/boottime_tools/bootanalyze/config.yaml" \ 23 LOOPS=3 \ 24 RESULTS_DIR="$ANDROID_BUILD_TOP/bootAnalyzeResults" \ 25 $PWD/system/extras/boottime_tools/bootanalyze/bootanalyze.sh 26' 27 exit 28} 29 30 31if [[ -z $ANDROID_BUILD_TOP ]]; then 32 echo 'Error: you need to specify ANDROID_BUILD_TOP' 33 readme 34fi 35echo "ANDROID_BUILD_TOP=$ANDROID_BUILD_TOP" 36SCRIPT_DIR="$ANDROID_BUILD_TOP/system/extras/boottime_tools/bootanalyze" 37 38 39if [[ -z $CONFIG_YMAL ]]; then 40 CONFIG_YMAL="$SCRIPT_DIR/config.yaml" 41fi 42echo "CONFIG_YMAL=$CONFIG_YMAL" 43 44 45if [[ -z $RESULTS_DIR ]]; then 46 RESULTS_DIR="$PWD/bootAnalyzeResults" 47fi 48echo "RESULTS_DIR=$RESULTS_DIR" 49mkdir -p $RESULTS_DIR 50 51 52adb shell 'touch /data/bootchart/enabled' 53 54if [[ -z $LOOPS ]]; then 55 LOOPS=1 56fi 57echo "Analyzing boot-time for LOOPS=$LOOPS" 58START=1 59 60SLEEP_SEC=30 61for (( l=$START; l<=$LOOPS; l++ )); do 62 echo -n "Loop: $l" 63 SECONDS=0 64 $SCRIPT_DIR/bootanalyze.py -c $CONFIG_YMAL -G 4M -r -b > "$RESULTS_DIR/boot$l.txt" 65 echo "$SECONDS sec." 66 cp /tmp/android-bootchart/bootchart.tgz "$RESULTS_DIR/bootchart$l.tgz" 67 echo "Sleep for $SLEEP_SEC sec." 68 sleep $SLEEP_SEC 69done 70 71echo 72echo "Complete $LOOPS"