1cc1dc7a3Sopenharmony_ci# Profiling astcenc
2cc1dc7a3Sopenharmony_ci
3cc1dc7a3Sopenharmony_ciThis page contains some developer notes on profiling `astcenc` using command
4cc1dc7a3Sopenharmony_ciline tools on Linux hosts.
5cc1dc7a3Sopenharmony_ci
6cc1dc7a3Sopenharmony_ci## Building for profiling
7cc1dc7a3Sopenharmony_ci
8cc1dc7a3Sopenharmony_ciIt is recommended to profile release builds, but you will need debug symbols.
9cc1dc7a3Sopenharmony_ciIt is also recommended to disable link-time optimization to get call stacks
10cc1dc7a3Sopenharmony_cithat vaguely resemble the source code, although beware because this means that
11cc1dc7a3Sopenharmony_ciyou are not quite profiling the reality of full release builds.
12cc1dc7a3Sopenharmony_ci
13cc1dc7a3Sopenharmony_ciBoth of these can be achieved using the following CMake build type:
14cc1dc7a3Sopenharmony_ci
15cc1dc7a3Sopenharmony_ci```shell
16cc1dc7a3Sopenharmony_ci -DCMAKE_BUILD_TYPE=RelWithDebInfo
17cc1dc7a3Sopenharmony_ci```
18cc1dc7a3Sopenharmony_ci
19cc1dc7a3Sopenharmony_ci## Running Callgrind tools
20cc1dc7a3Sopenharmony_ci
21cc1dc7a3Sopenharmony_ciWe provide a helper script that wraps Callgrind for hotspot profiling, although
22cc1dc7a3Sopenharmony_cibeware that it only currently supports profiling LDR input images and the
23cc1dc7a3Sopenharmony_cisingle compression mode.
24cc1dc7a3Sopenharmony_ci
25cc1dc7a3Sopenharmony_ciThis script requires the following tools on your `PATH`:
26cc1dc7a3Sopenharmony_ci
27cc1dc7a3Sopenharmony_ci  * valgrind
28cc1dc7a3Sopenharmony_ci  * gprof2dot
29cc1dc7a3Sopenharmony_ci  * dot
30cc1dc7a3Sopenharmony_ci
31cc1dc7a3Sopenharmony_ciRun the helper script from the root of the repository using, e.g.:
32cc1dc7a3Sopenharmony_ci
33cc1dc7a3Sopenharmony_ci```shell
34cc1dc7a3Sopenharmony_cipython3 ./Test/astc_profile_valgrind.py <image.png> --test-quality fastest
35cc1dc7a3Sopenharmony_ci```
36cc1dc7a3Sopenharmony_ci
37cc1dc7a3Sopenharmony_ciThe output will be two files:
38cc1dc7a3Sopenharmony_ci
39cc1dc7a3Sopenharmony_ci- perf_&lt;quality&gt;.png: an annotated call graph.
40cc1dc7a3Sopenharmony_ci- perf_&lt;quality&gt;.txt: the top N functions table.
41cc1dc7a3Sopenharmony_ci
42cc1dc7a3Sopenharmony_ci### Viewing disassembly
43cc1dc7a3Sopenharmony_ci
44cc1dc7a3Sopenharmony_ciStandard syntax x86-64 disassembly can be generated using:
45cc1dc7a3Sopenharmony_ci
46cc1dc7a3Sopenharmony_ci```shell
47cc1dc7a3Sopenharmony_ciobjdump -C -M intel --no-show-raw -d -S <binary> > dis.txt
48cc1dc7a3Sopenharmony_ci```
49cc1dc7a3Sopenharmony_ci
50cc1dc7a3Sopenharmony_ci- - -
51cc1dc7a3Sopenharmony_ci
52cc1dc7a3Sopenharmony_ci_Copyright © 2020-2022, Arm Limited and contributors. All rights reserved._
53