1*89a63228SAndroid Build Coastguard Worker 2*89a63228SAndroid Build Coastguard Worker# Run Caliper benchmark tests using vogar on a rooted device 3*89a63228SAndroid Build Coastguard Worker 4*89a63228SAndroid Build Coastguard Worker- It uses the [Caliper library](https://github.com/google/caliper) developed by Google. 5*89a63228SAndroid Build Coastguard Worker- Vogar source codes can be found at `external/vogar`. 6*89a63228SAndroid Build Coastguard Worker 7*89a63228SAndroid Build Coastguard Worker1. Preparation 8*89a63228SAndroid Build Coastguard Worker 9*89a63228SAndroid Build Coastguard Worker```shell 10*89a63228SAndroid Build Coastguard Worker# vogar requires com.android.art.testing 11*89a63228SAndroid Build Coastguard Workerm vogar com.android.art.testing 12*89a63228SAndroid Build Coastguard Worker# remount if you haven't done so. 13*89a63228SAndroid Build Coastguard Workeradb root && adb remount && adb reboot && adb wait-for-device root 14*89a63228SAndroid Build Coastguard Workercd libcore/benchmarks/src 15*89a63228SAndroid Build Coastguard Worker``` 16*89a63228SAndroid Build Coastguard Worker 17*89a63228SAndroid Build Coastguard WorkerExtra options to reduce noise: 18*89a63228SAndroid Build Coastguard Worker```shell 19*89a63228SAndroid Build Coastguard Workeradb shell stop # to kill frameworks and zygote 20*89a63228SAndroid Build Coastguard Worker``` 21*89a63228SAndroid Build Coastguard Worker 22*89a63228SAndroid Build Coastguard Worker2. Run an individual test 23*89a63228SAndroid Build Coastguard Worker 24*89a63228SAndroid Build Coastguard Worker```shell 25*89a63228SAndroid Build Coastguard Workervogar --benchmark benchmarks/regression/ScannerBenchmark.java 26*89a63228SAndroid Build Coastguard Worker``` 27*89a63228SAndroid Build Coastguard Worker 28*89a63228SAndroid Build Coastguard WorkerThe source code of the tests can be found at `src/benchmarks/` 29*89a63228SAndroid Build Coastguard Worker 30*89a63228SAndroid Build Coastguard Worker# Run Jetpack benchmark tests 31*89a63228SAndroid Build Coastguard WorkerDocs about Jetpack Benchmark can be found at 32*89a63228SAndroid Build Coastguard Worker[https://developer.android.com/studio/profile/benchmarking-overview]() 33*89a63228SAndroid Build Coastguard Worker 34*89a63228SAndroid Build Coastguard Worker1. Preparation 35*89a63228SAndroid Build Coastguard Worker 36*89a63228SAndroid Build Coastguard WorkerTo lock CPU clocks on a rooted device, 37*89a63228SAndroid Build Coastguard Workerrun the script provided at [https://developer.android.com/studio/profile/run-benchmarks-in-ci#clock-locking](). 38*89a63228SAndroid Build Coastguard Worker 39*89a63228SAndroid Build Coastguard Worker2. Run an individual test 40*89a63228SAndroid Build Coastguard Worker```shell 41*89a63228SAndroid Build Coastguard Workeratest LibcoreBenchmarkTests:libcore.benchmark.FormatterTest#stringFormatNumber_allLocales 42*89a63228SAndroid Build Coastguard Worker``` 43*89a63228SAndroid Build Coastguard Worker 44*89a63228SAndroid Build Coastguard WorkerThe source code of the tests can be found at `src_androidx/libcore/benchmark/` 45*89a63228SAndroid Build Coastguard Worker 46*89a63228SAndroid Build Coastguard Worker## Outdated documentation / Not working 47*89a63228SAndroid Build Coastguard Worker 48*89a63228SAndroid Build Coastguard Worker###VM Options 49*89a63228SAndroid Build Coastguard Worker 50*89a63228SAndroid Build Coastguard Worker 51*89a63228SAndroid Build Coastguard WorkerThe VM's configuration will have a substantial impact on performance. 52*89a63228SAndroid Build Coastguard WorkerUse Caliper's -J<name> <value 1>,<value 2>,<value 3> syntax to compare different VM options. For example: 53*89a63228SAndroid Build Coastguard Worker```shell 54*89a63228SAndroid Build Coastguard Workervogar --benchmark ~/svn/dalvik/benchmarks/regression/CrespoFileIoRegressionBenchmark.java \ 55*89a63228SAndroid Build Coastguard Worker-- -Jgc -Xgc:noconcurrent,-Xgc:concurrent -Jint -Xint:fast,-Xint:jit,-Xint:portable 56*89a63228SAndroid Build Coastguard Worker``` 57*89a63228SAndroid Build Coastguard Worker 58