1# Benchmarking Build Performance of Android Clang
2
3Build performance is a vital metric as it affects development velocity, CI
4resource usage and the headroom for more sophisticated optimisation techniques.
5We heavily optimise Android Clang for peak performance.
6
7The Android Clang's compiler wrapper provides a convenient way to analyse the
8time spent building the Android platform. It can be produced by running:
9
10```
11rm -f /tmp/rusage.txt
12TOOLCHAIN_RUSAGE_OUTPUT=/tmp/rusage.txt m -j{processor count / 4}
13```
14
15We decrease the parallelism to reduce noise caused by resource contention. Also
16make sure RBE is off for the build. The resulting `rusage.txt` can be analysed
17with the following Python script:
18
19```
20#! /usr/bin/env python3
21
22import json
23import sys
24
25total_clang_time = 0
26total_clang_tidy_time = 0
27
28with open(sys.argv[1], 'r') as rusage:
29  for line in rusage:
30    data = json.loads(line)
31    if 'clang-tidy' in data['compiler']:
32      total_clang_tidy_time += data['elapsed_real_time']
33    else:
34      total_clang_time += data['elapsed_real_time']
35
36print('Total clang time', total_clang_time)
37print('Total clang-tidy time', total_clang_tidy_time)
38```
39