@@ -20,29 +20,17 @@ cold-start.
2020 sure ` set(GENERATE_PROFILES ON) ` is not commented. You need to pass any
2121 optimization flag except ` -O0 ` . The mapping file is not generated and the
2222 profile instrumentation does not work without an optimization flag.
23- 1 . Run the app on Android Studio. You can either run it on a physical or virtual
23+ 2 . Run the app on Android Studio. You can either run it on a physical or virtual
2424 device. You will see "Hello World" on the screen.
25- 1 . To pull the data from the device, you'll need to move it from an app-writable
26- directory to a shell readable directory for adb pull. We also need to
27- transfer the output into hexadecimal format .
25+ 3 . To pull the data from the device, you'll need to move it from an app-writable
26+ directory to a shell readable directory for adb pull.
27+ 4 . Use ` llvm-profdata ` to merge all the raw files and create an orderfile .
2828
2929```
30- adb shell "run-as com.example.orderfiledemo sh -c 'cat /data/user/0/com.example.orderfiledemo/cache/demo.output.order' | cat > /data/local/tmp/demo.output.order"
31- adb pull /data/local/tmp/demo.output.order .
32-
33- # Convert to hexdeciaml format on Linux, Mac, or ChromeOS
34- hexdump -C demo.output.order > demo.prof
35-
36- # Convert to hexdecimal format on Windows
37- certutil -f -encodeHex demo.output.order demo.prof
38- ```
39-
40- 4 . Once you get both mapping file and profile file, you can use
41- [ this script] ( https://android.googlesource.com/toolchain/pgo-profiles/+/refs/heads/main/scripts/create_orderfile.py )
42- to create the order file:
43-
44- ```
45- python3 create_orderfile.py --profile-file demo.prof --mapping-file mapping.txt --output app/src/main/cpp/demo.orderfile
30+ adb shell "run-as com.example.orderfiledemo sh -c 'cat /data/user/0/com.example.orderfiledemo/cache/demo.profraw' | cat > /data/local/tmp/demo.profraw"
31+ adb pull /data/local/tmp/demo.profraw .
32+ <NDK_PATH>/toolchains/llvm/prebuilt/<ARCH>/bin/llvm-profdata merge demo.profraw -o demo.profdata
33+ <NDK_PATH>/toolchains/llvm/prebuilt/<ARCH>/bin/llvm-profdata order demo.profdata -o demo.orderfile
4634```
4735
4836## Load Steps
@@ -51,10 +39,11 @@ python3 create_orderfile.py --profile-file demo.prof --mapping-file mapping.txt
5139 ` set(USE_PROFILE "${CMAKE_SOURCE_DIR}/demo.orderfile") ` and make sure
5240 ` set(GENERATE_PROFILES ON) ` is commented.
5341
54- 1 . If you want to validate the shared library's layout is different, you need to
42+ 2 . If you want to validate the shared library's layout is different, you need to
5543 find ` liborderfiledemo.so ` and run ` nm `
5644
5745```
46+ mv demo.orderfile app/src/main/cpp
5847nm -n liborderfiledemo.so
5948```
6049
0 commit comments