Merge "Ensure that virtmgr and crosvm runs with max profile during benchmarking" into main am: 7239a7391e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/2984355
Change-Id: I37099538477c95bd811d80d2c0d64b18730b73b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
index ba02067..acd6f2c 100644
--- a/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
+++ b/tests/benchmark/src/java/com/android/microdroid/benchmark/MicrodroidBenchmarks.java
@@ -127,12 +127,21 @@
}
}
+ public MicrodroidBenchmarks() throws IOException {
+ // See b/325745564#comment28. Calling this method here ensures that threads spawned for
+ // @Test methods are with the desired task profile. If this is called in @Before, the task
+ // profile may not be set to the test threads because they may be spanwed prior to the
+ // execution of the @Before method (though the test methods will be executed after the
+ // @Before method). With this, children of this benchmark process (virtmgr and crosvm) also
+ // run in the desired task profile.
+ setMaxPerformanceTaskProfile();
+ }
+
@Before
public void setup() throws IOException {
grantPermission(VirtualMachine.MANAGE_VIRTUAL_MACHINE_PERMISSION);
grantPermission(VirtualMachine.USE_CUSTOM_VIRTUAL_MACHINE_PERMISSION);
prepareTestSetup(mProtectedVm, mGki);
- setMaxPerformanceTaskProfile();
mInstrumentation = getInstrumentation();
}