Baseline profiles doesn't work on unrooted device?

713 Views Asked by At

I created a baseline profile for the project according to the instructions here; Baseline Profiles

then I put baseline-prof.txt in the src/main folder and add dependencies in app.build.gradle
implementation 'androidx.profileinstaller:profileinstaller:1.3.0-alpha03'

After that, I generated a release apk and sideloaded it to my devices according to; Create and measure Baseline Profiles without Macrobenchmark.

Startup time is counted by ActivityTaskManager log:
I ActivityTaskManager: Displayed packageName/ActivityName +2s685ms

I have two devices, one rooted device and another unrooted device, both Android 10(Api29).
I compared startup time between baseline-profile and none on both devices, found it works on rooted device, startup time has reduced a lot when use baseline-profile, but there is no difference on unrooted device

I have some problems:

  1. Can baseline profile work on unrooted device?
  2. Why baseline profiles doesn't work on my device?
  3. I want to test baseline profile locally without benchmark, is there any way else? Can this way work on unrooted device?
1

There are 1 best solutions below

2
On
  1. Can baseline profile work on unrooted device?

Yes, Baseline Profiles can be installed on regular, un-rooted, devices. Gathering a profile used to require a rooted device, but that has been resolved as well.

  1. Why baseline profiles doesn't work on my device?

Generally speaking, measuring performance using the macrobenchmark library with the right flags, should give you reliable results and install the profile if required. You can run the StartupBenchmark from the API samples to see a comparison of startup time with and without profiles enabled.

  1. I want to test baseline profile locally without benchmark, is there any way else? Can this way work on unrooted device?

You can test and verify without the macrobenchmark library. It's easier to use the macrobenchmark library though as it does all the lifting and creates reproducible and statistically relevant results.

Manual testing can be unreliable as you need to execute several steps to ensure the profile is installed. It can take a while for a profile to be installed locally, through profileinstaller. This is to ensure that the device is in a state where profile installation won't take resources which can be used from a foreground process.