xref: /aosp_15_r20/build/bazel/scripts/incremental_build/canonical_perf.sh (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1#!/bin/bash
2#
3# Copyright (C) 2022 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
17#
18# Gather and print top-line performance metrics for the android build
19#
20readonly TOP="$(realpath "$(dirname "$0")/../../../..")"
21
22usage() {
23  cat <<EOF
24usage: $0 [-l LOG_DIR] [BUILD_TYPES]
25  -l    LOG_DIR should be outside of source tree, including not in out/,
26        because the whole tree will be cleaned during testing.
27example:
28 $0 soong prod
29EOF
30  exit 1
31}
32
33declare -a build_types
34while getopts "l:" opt; do
35  case "$opt" in
36  l) log_dir=$OPTARG ;;
37  ?) usage ;;
38  esac
39done
40shift $((OPTIND - 1))
41readonly -a build_types=("$@")
42
43log_dir=${log_dir:-"$TOP/../timing-$(date +%b%d-%H%M)"}
44log_dir=$(realpath "$log_dir")
45
46function build() {
47  date
48  set -x
49  if ! "$TOP/build/bazel/scripts/incremental_build/incremental_build.sh" \
50    --ignore-repo-diff --log-dir "$log_dir" \
51    ${build_types:+--build-types "${build_types[@]}"} \
52    "$@"; then
53    echo "See logs for errors"
54    exit 1
55  fi
56  set +x
57}
58build --cujs clean 'no change' 'create bionic/unreferenced.txt' 'modify Android.bp' -- droid
59build --cujs 'modify bionic/.*/stdio.cpp' --append-csv libc
60build --cujs 'modify .*/adb/daemon/main.cpp' --append-csv adbd
61build --cujs 'modify frameworks/.*/View.java' --append-csv framework
62build --cujs 'modify frameworks/.*/Settings.java' --append-csv framework-minus-apex
63