Include 'debug.hypervisor.metrics_tag' in metric names
Vendor code can set a property to tag performance metric names. This can be useful if devices in the lab have varying performance characteristics. Test: atest -p packages/modules/Virtualization:avf-postsubmit Change-Id: I46478471571639a145079cdc296b9824f1328fc3
This commit is contained in:
parent
cd0fa45b95
commit
cab9d1b964
|
@ -58,7 +58,7 @@ public class ComposBenchmark extends MicrodroidDeviceTestBase {
|
|||
private static final int BUFFER_SIZE = 1024;
|
||||
private static final int ROUND_COUNT = 5;
|
||||
private static final double NANOS_IN_SEC = 1_000_000_000.0;
|
||||
private static final String METRIC_PREFIX = "avf_perf/compos/";
|
||||
private static final String METRIC_PREFIX = getMetricPrefix() + "compos/";
|
||||
|
||||
private final MetricsProcessor mMetricsProcessor = new MetricsProcessor(METRIC_PREFIX);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
@RunWith(Parameterized.class)
|
||||
public class MicrodroidBenchmarks extends MicrodroidDeviceTestBase {
|
||||
private static final String TAG = "MicrodroidBenchmarks";
|
||||
private static final String METRIC_NAME_PREFIX = "avf_perf/microdroid/";
|
||||
private static final String METRIC_NAME_PREFIX = getMetricPrefix() + "microdroid/";
|
||||
private static final int IO_TEST_TRIAL_COUNT = 5;
|
||||
|
||||
@Rule public Timeout globalTimeout = Timeout.seconds(300);
|
||||
|
|
|
@ -70,14 +70,14 @@ public final class AVFHostTestCase extends MicrodroidHostTestCaseBase {
|
|||
private static final int BOOT_COMPLETE_TIMEOUT_MS = 10 * 60 * 1000;
|
||||
private static final double NANOS_IN_SEC = 1_000_000_000.0;
|
||||
private static final int ROUND_COUNT = 5;
|
||||
private static final String METRIC_PREFIX = "avf_perf/hostside/";
|
||||
|
||||
private final MetricsProcessor mMetricsProcessor = new MetricsProcessor(METRIC_PREFIX);
|
||||
private MetricsProcessor mMetricsProcessor;
|
||||
@Rule public TestMetrics mMetrics = new TestMetrics();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
testIfDeviceIsCapable(getDevice());
|
||||
mMetricsProcessor = new MetricsProcessor(getMetricPrefix() + "hostside/");
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -20,6 +20,7 @@ java_library_static {
|
|||
static_libs: [
|
||||
"androidx.test.runner",
|
||||
"androidx.test.ext.junit",
|
||||
"MicrodroidTestHelper",
|
||||
"VirtualizationTestHelper",
|
||||
"truth-prebuilt",
|
||||
],
|
||||
|
|
|
@ -24,6 +24,12 @@ import java.util.Map;
|
|||
public final class MetricsProcessor {
|
||||
private final String mPrefix;
|
||||
|
||||
public static String getMetricPrefix(String debugTag) {
|
||||
return "avf_perf"
|
||||
+ ((debugTag != null && !debugTag.isEmpty()) ? "[" + debugTag + "]" : "")
|
||||
+ "/";
|
||||
}
|
||||
|
||||
public MetricsProcessor(String prefix) {
|
||||
mPrefix = prefix;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import android.util.Log;
|
|||
import androidx.annotation.CallSuper;
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.microdroid.test.common.MetricsProcessor;
|
||||
import com.android.virt.VirtualizationTestHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -48,6 +49,11 @@ public abstract class MicrodroidDeviceTestBase {
|
|||
return VirtualizationTestHelper.isCuttlefish(SystemProperties.get("ro.product.name"));
|
||||
}
|
||||
|
||||
public static String getMetricPrefix() {
|
||||
return MetricsProcessor.getMetricPrefix(
|
||||
SystemProperties.get("debug.hypervisor.metrics_tag"));
|
||||
}
|
||||
|
||||
// TODO(b/220920264): remove Inner class; this is a hack to hide virt APEX types
|
||||
protected static class Inner {
|
||||
private final boolean mProtectedVm;
|
||||
|
|
|
@ -11,6 +11,7 @@ java_library_host {
|
|||
"truth-prebuilt",
|
||||
],
|
||||
static_libs: [
|
||||
"MicrodroidTestHelper",
|
||||
"VirtualizationTestHelper",
|
||||
],
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
|
|||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
|
||||
import com.android.microdroid.test.common.MetricsProcessor;
|
||||
import com.android.tradefed.build.IBuildInfo;
|
||||
import com.android.tradefed.device.DeviceNotAvailableException;
|
||||
import com.android.tradefed.device.ITestDevice;
|
||||
|
@ -97,6 +98,11 @@ public abstract class MicrodroidHostTestCaseBase extends BaseHostJUnit4Test {
|
|||
return VirtualizationTestHelper.isCuttlefish(getDevice().getProperty("ro.product.name"));
|
||||
}
|
||||
|
||||
protected String getMetricPrefix() throws Exception {
|
||||
return MetricsProcessor.getMetricPrefix(
|
||||
getDevice().getProperty("debug.hypervisor.metrics_tag"));
|
||||
}
|
||||
|
||||
public static void testIfDeviceIsCapable(ITestDevice androidDevice) throws Exception {
|
||||
assumeTrue("Need an actual TestDevice", androidDevice instanceof TestDevice);
|
||||
TestDevice testDevice = (TestDevice) androidDevice;
|
||||
|
|
|
@ -93,6 +93,8 @@ public class MicrodroidTestCase extends MicrodroidHostTestCaseBase {
|
|||
@Rule public TestName mTestName = new TestName();
|
||||
@Rule public TestMetrics mMetrics = new TestMetrics();
|
||||
|
||||
private String mMetricPrefix;
|
||||
|
||||
private int minMemorySize() throws DeviceNotAvailableException {
|
||||
CommandRunner android = new CommandRunner(getDevice());
|
||||
String abi = android.run("getprop", "ro.product.cpu.abi");
|
||||
|
@ -792,7 +794,7 @@ public class MicrodroidTestCase extends MicrodroidHostTestCaseBase {
|
|||
|
||||
for (Map.Entry<String, Long> stat : getProcMemInfo().entrySet()) {
|
||||
mMetrics.addTestMetric(
|
||||
"avf_perf/microdroid/meminfo/" + stat.getKey().toLowerCase(),
|
||||
mMetricPrefix + "meminfo/" + stat.getKey().toLowerCase(),
|
||||
stat.getValue().toString());
|
||||
}
|
||||
|
||||
|
@ -800,7 +802,7 @@ public class MicrodroidTestCase extends MicrodroidHostTestCaseBase {
|
|||
for (Map.Entry<String, Long> stat : getProcSmapsRollup(proc.mPid).entrySet()) {
|
||||
String name = stat.getKey().toLowerCase();
|
||||
mMetrics.addTestMetric(
|
||||
"avf_perf/microdroid/smaps/" + name + "/" + proc.mName,
|
||||
mMetricPrefix + "smaps/" + name + "/" + proc.mName,
|
||||
stat.getValue().toString());
|
||||
}
|
||||
}
|
||||
|
@ -845,6 +847,7 @@ public class MicrodroidTestCase extends MicrodroidHostTestCaseBase {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
testIfDeviceIsCapable(getDevice());
|
||||
mMetricPrefix = getMetricPrefix() + "microdroid/";
|
||||
|
||||
prepareVirtualizationTestSetup(getDevice());
|
||||
|
||||
|
|
Loading…
Reference in New Issue