Add documentation about libcore benchmark tests

Also, add a hardcoded debuggable flag to Jetpack benchmark APK manifest.
It should be false by default, and recommend to hardcode it too.

Bug: 204160442
Test: n/a
Change-Id: I3ce73610b327857f18c5225f40492e147ec198a7
diff --git a/README.md b/README.md
index 9fbbf08..6044f3f 100644
--- a/README.md
+++ b/README.md
@@ -9,3 +9,5 @@
 [Import files from OpenJDK](tools/expected_upstream/README.md)
 
 [Add nullability annotations](ojluni/annotations/README)
+
+[Run benchmark tests](benchmarks/README.md)
diff --git a/benchmarks/AndroidManifest.xml b/benchmarks/AndroidManifest.xml
index 8674b09..611b18b 100644
--- a/benchmarks/AndroidManifest.xml
+++ b/benchmarks/AndroidManifest.xml
@@ -17,6 +17,9 @@
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
           package="libcore.benchmark">
+    <!-- Important: disable debuggable for accurate performance results -->
+    <application android:debuggable="false"/>
+
     <instrumentation
         android:name="androidx.benchmark.junit4.AndroidBenchmarkRunner"
         android:targetPackage="libcore.benchmark"/>
diff --git a/benchmarks/README.md b/benchmarks/README.md
new file mode 100644
index 0000000..7fef94d
--- /dev/null
+++ b/benchmarks/README.md
@@ -0,0 +1,57 @@
+
+# Run Caliper benchmark tests using vogar on a rooted device
+
+- It uses the [Caliper library](https://github.com/google/caliper) developed by Google.
+- Vogar source codes can be found at `external/vogar`.
+
+1. Preparation
+
+```shell
+# vogar requires com.android.art.testing
+m vogar com.android.art.testing
+# remount if you haven't done so.
+adb root && adb remount && adb reboot && adb wait-for-device root
+cd libcore/benchmarks/src
+```
+
+Extra options to reduce noise:
+```shell
+adb shell stop # to kill frameworks and zygote
+```
+
+2. Run an individual test
+
+```shell
+vogar --benchmark benchmarks/regression/ScannerBenchmark.java
+```
+
+The source code of the tests can be found at `src/benchmarks/`
+
+# Run Jetpack benchmark tests
+Docs about Jetpack Benchmark can be found at
+[https://developer.android.com/studio/profile/benchmarking-overview]()
+
+1. Preparation
+
+To lock CPU clocks on a rooted device,
+run the script provided at [https://developer.android.com/studio/profile/run-benchmarks-in-ci#clock-locking]().
+
+2. Run an individual test
+```shell
+atest LibcoreBenchmarkTests:libcore.benchmark.FormatterTest#stringFormatNumber_allLocales
+```
+
+The source code of the tests can be found at `src_androidx/libcore/benchmark/`
+
+## Outdated documentation / Not working
+
+###VM Options
+
+
+The VM's configuration will have a substantial impact on performance.
+Use Caliper's -J<name> <value 1>,<value 2>,<value 3> syntax to compare different VM options. For example:
+```shell
+vogar --benchmark ~/svn/dalvik/benchmarks/regression/CrespoFileIoRegressionBenchmark.java \
+-- -Jgc -Xgc:noconcurrent,-Xgc:concurrent -Jint -Xint:fast,-Xint:jit,-Xint:portable
+```
+