xref: /aosp_15_r20/toolchain/pgo-profiles/scripts/afdo_summary.sh (revision 9cb1bd80a1c19d9e545b00c0767d354ba81e1676)
1*9cb1bd80SAndroid Build Coastguard Worker#!/bin/bash
2*9cb1bd80SAndroid Build Coastguard Worker
3*9cb1bd80SAndroid Build Coastguard Worker# Copyright (C) 2023 The Android Open Source Project
4*9cb1bd80SAndroid Build Coastguard Worker#
5*9cb1bd80SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
6*9cb1bd80SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
7*9cb1bd80SAndroid Build Coastguard Worker# You may obtain a copy of the License at
8*9cb1bd80SAndroid Build Coastguard Worker#
9*9cb1bd80SAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
10*9cb1bd80SAndroid Build Coastguard Worker#
11*9cb1bd80SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
12*9cb1bd80SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
13*9cb1bd80SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*9cb1bd80SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
15*9cb1bd80SAndroid Build Coastguard Worker# limitations under the License.
16*9cb1bd80SAndroid Build Coastguard Worker
17*9cb1bd80SAndroid Build Coastguard Workerset -e
18*9cb1bd80SAndroid Build Coastguard Worker
19*9cb1bd80SAndroid Build Coastguard Workerif [ -z ${ANDROID_BUILD_TOP} ]
20*9cb1bd80SAndroid Build Coastguard Workerthen
21*9cb1bd80SAndroid Build Coastguard Worker  echo "Source envsetup.sh first"
22*9cb1bd80SAndroid Build Coastguard Worker  exit 1
23*9cb1bd80SAndroid Build Coastguard Workerfi
24*9cb1bd80SAndroid Build Coastguard Worker
25*9cb1bd80SAndroid Build Coastguard Workercd $(dirname "$0")/..
26*9cb1bd80SAndroid Build Coastguard Worker
27*9cb1bd80SAndroid Build Coastguard WorkerSUMMARY_FILE=AFDO_SUMMARY.txt
28*9cb1bd80SAndroid Build Coastguard Worker
29*9cb1bd80SAndroid Build Coastguard Workerecho "Top functions from sampling profiles" > ${SUMMARY_FILE}
30*9cb1bd80SAndroid Build Coastguard Workerecho "Auto-generated by scripts/afdo_summary.sh" >> ${SUMMARY_FILE}
31*9cb1bd80SAndroid Build Coastguard Workerecho "=========================================" >> ${SUMMARY_FILE}
32*9cb1bd80SAndroid Build Coastguard Workerecho >> ${SUMMARY_FILE}
33*9cb1bd80SAndroid Build Coastguard Worker
34*9cb1bd80SAndroid Build Coastguard Workerfor f in sampling/*.afdo;
35*9cb1bd80SAndroid Build Coastguard Workerdo
36*9cb1bd80SAndroid Build Coastguard Worker  echo ${f} >> ${SUMMARY_FILE}
37*9cb1bd80SAndroid Build Coastguard Worker  echo "====" >> ${SUMMARY_FILE}
38*9cb1bd80SAndroid Build Coastguard Worker  llvm-profdata show --sample --topn=16 ${f} | grep "Total sample" -A16 | tail -n+2 | tr -s ' ' | cut -d' ' -f6 | llvm-cxxfilt >> ${SUMMARY_FILE}
39*9cb1bd80SAndroid Build Coastguard Worker  echo >> ${SUMMARY_FILE}
40*9cb1bd80SAndroid Build Coastguard Worker  echo >> ${SUMMARY_FILE}
41*9cb1bd80SAndroid Build Coastguard Workerdone
42