summaryrefslogtreecommitdiff
path: root/boottime_tools
diff options
context:
space:
mode:
authorSam Lin <samlin@google.com>2020-10-15 22:27:09 -0700
committerSam Lin <samlin@google.com>2020-10-15 22:27:09 -0700
commit97acf18e09f007bc3f4335f96ddb75af9a2a08ad (patch)
tree57b3b2fcc423aa61f26233f21b8accecc41695e0 /boottime_tools
parente7a821d677e74721be51fd0618f30e0338725c77 (diff)
downloadextras-97acf18e09f007bc3f4335f96ddb75af9a2a08ad.tar.gz
Add bootanalyze.sh, update readme & fix yaml warning
Bug: 171016031 Test: ./system/extras/boottime_tools/bootanalyze/bootanalyze.sh Change-Id: I77c7e96deffa867e8237227925da60fc83ab6d65
Diffstat (limited to 'boottime_tools')
-rw-r--r--boottime_tools/bootanalyze/README.md26
-rwxr-xr-xboottime_tools/bootanalyze/bootanalyze.py6
-rwxr-xr-xboottime_tools/bootanalyze/bootanalyze.sh72
-rw-r--r--boottime_tools/bootanalyze/bugreport_anayze.py2
4 files changed, 101 insertions, 5 deletions
diff --git a/boottime_tools/bootanalyze/README.md b/boottime_tools/bootanalyze/README.md
index d6e0412f..038e1452 100644
--- a/boottime_tools/bootanalyze/README.md
+++ b/boottime_tools/bootanalyze/README.md
@@ -1,7 +1,31 @@
-# bootanalyze #
+# bootanalyze
The bootanalyze tool helps to profile boot timing.
+[TOC]
+
+## Preliminaries
+
+* Need to access "su" on the Device Under Test, e.g. a userdebug build.
+* This only works on Linux with Python 2.7, PyYAML and pybootchartgui.
+
+```
+sudo pip install pyyaml
+sudo apt-get install pybootchartgui
+```
+
+## Examples
+
+* bootanalyze.sh provides an example to analyze boot-times and bootcharts.
+```
+ANDROID_BUILD_TOP="$PWD" \
+CONFIG_YMAL="$ANDROID_BUILD_TOP/system/extras/boottime_tools/bootanalyze/config.yaml" \
+ LOOPS=3 \
+ RESULTS_DIR="$ANDROID_BUILD_TOP/bootAnalyzeResults" \
+ $PWD/system/extras/boottime_tools/bootanalyze/bootanalyze.sh
+```
+
+## config.yaml
Per specific product modify config.yaml file to include
events you are looking for. Config should look like:
diff --git a/boottime_tools/bootanalyze/bootanalyze.py b/boottime_tools/bootanalyze/bootanalyze.py
index ef5c5273..8f37094d 100755
--- a/boottime_tools/bootanalyze/bootanalyze.py
+++ b/boottime_tools/bootanalyze/bootanalyze.py
@@ -84,7 +84,7 @@ def main():
value = float(kv[1])
components_to_monitor[key] = value
- cfg = yaml.load(args.config)
+ cfg = yaml.load(args.config, Loader=yaml.FullLoader)
if args.stressfs:
if run_adb_cmd('install -r -g ' + args.stressfs) != 0:
@@ -818,7 +818,7 @@ def stddev(data):
return math.sqrt(variance)
def grab_bootchart(boot_chart_file_name):
- subprocess.call("./system/core/init/grab-bootchart.sh", shell=True)
+ subprocess.call("$ANDROID_BUILD_TOP/system/core/init/grab-bootchart.sh", shell=True)
print "Saving boot chart as " + boot_chart_file_name + ".tgz"
subprocess.call('cp /tmp/android-bootchart/bootchart.tgz ./' + boot_chart_file_name + '.tgz',\
shell=True)
@@ -830,7 +830,7 @@ def grab_systrace(systrace_file_name):
f.write("TRACE:\n")
run_adb_shell_cmd_as_root("cat /d/tracing/trace >> " + trace_file)
html_file = systrace_file_name + ".html"
- subprocess.call("./external/chromium-trace/systrace.py --from-file=" + trace_file + " -o " +\
+ subprocess.call("$ANDROID_BUILD_TOP/external/chromium-trace/systrace.py --from-file=" + trace_file + " -o " +\
html_file, shell=True)
if __name__ == '__main__':
diff --git a/boottime_tools/bootanalyze/bootanalyze.sh b/boottime_tools/bootanalyze/bootanalyze.sh
new file mode 100755
index 00000000..7fce2e1c
--- /dev/null
+++ b/boottime_tools/bootanalyze/bootanalyze.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+readme() {
+ echo '
+Analyze boot-time & bootchart
+e.g.
+ANDROID_BUILD_TOP="$PWD" \
+CONFIG_YMAL="$ANDROID_BUILD_TOP/system/extras/boottime_tools/bootanalyze/config.yaml" \
+ LOOPS=3 \
+ RESULTS_DIR="$ANDROID_BUILD_TOP/bootAnalyzeResults" \
+ $PWD/system/extras/boottime_tools/bootanalyze/bootanalyze.sh
+'
+ exit
+}
+
+
+if [[ -z $ANDROID_BUILD_TOP ]]; then
+ echo 'Error: you need to specify ANDROID_BUILD_TOP'
+ readme
+fi
+echo "ANDROID_BUILD_TOP=$ANDROID_BUILD_TOP"
+SCRIPT_DIR="$ANDROID_BUILD_TOP/system/extras/boottime_tools/bootanalyze"
+
+
+if [[ -z $CONFIG_YMAL ]]; then
+ CONFIG_YMAL="$SCRIPT_DIR/config.yaml"
+fi
+echo "CONFIG_YMAL=$CONFIG_YMAL"
+
+
+if [[ -z $RESULTS_DIR ]]; then
+ RESULTS_DIR="$PWD/bootAnalyzeResults"
+fi
+echo "RESULTS_DIR=$RESULTS_DIR"
+mkdir -p $RESULTS_DIR
+
+
+adb shell 'touch /data/bootchart/enabled'
+
+if [[ -z $LOOPS ]]; then
+ LOOPS=1
+fi
+echo "Analyzing boot-time for LOOPS=$LOOPS"
+START=1
+
+SLEEP_SEC=30
+for (( l=$START; l<=$LOOPS; l++ )); do
+ echo -n "Loop: $l"
+ SECONDS=0
+ $SCRIPT_DIR/bootanalyze.py -c $CONFIG_YMAL -G 4M -r -b > "$RESULTS_DIR/boot$l.txt"
+ echo "$SECONDS sec."
+ cp /tmp/android-bootchart/bootchart.tgz "$RESULTS_DIR/bootchart$l.tgz"
+ echo "Sleep for $SLEEP_SEC sec."
+ sleep $SLEEP_SEC
+done
+
+echo
+echo "Complete $LOOPS" \ No newline at end of file
diff --git a/boottime_tools/bootanalyze/bugreport_anayze.py b/boottime_tools/bootanalyze/bugreport_anayze.py
index 2575ebf6..3ea7552e 100644
--- a/boottime_tools/bootanalyze/bugreport_anayze.py
+++ b/boottime_tools/bootanalyze/bugreport_anayze.py
@@ -138,7 +138,7 @@ class Parser:
self.re_log_start = re.compile(LOG_START_PATTERN)
self.re_log_end = re.compile(LOG_END_PATTERN)
self.f = bugreport_file
- cfg = yaml.load(config_file)
+ cfg = yaml.load(config_file, Loader=yaml.FullLoader)
self.event_patterns = {key: re.compile(pattern)
for key, pattern in cfg['events'].iteritems()}
self.timing_patterns = {key: re.compile(pattern)