Add vm starting time benchmark
VM starting time means the elapsed time from calling vm.run() API to vCPU. Bug: 240395191 Test: atest MicrodroidBenchmarks Change-Id: I34dc28752d3956bbfc81af321f12395501b80735
This commit is contained in:
parent
9b674ec8b4
commit
db41bf5a0b
|
@ -122,6 +122,7 @@ public class MicrodroidBenchmarks extends MicrodroidDeviceTestBase {
|
|||
|
||||
final int trialCount = 10;
|
||||
|
||||
List<Double> vmStartingTimeMetrics = new ArrayList<>();
|
||||
List<Double> bootTimeMetrics = new ArrayList<>();
|
||||
List<Double> bootloaderTimeMetrics = new ArrayList<>();
|
||||
List<Double> kernelBootTimeMetrics = new ArrayList<>();
|
||||
|
@ -139,13 +140,15 @@ public class MicrodroidBenchmarks extends MicrodroidDeviceTestBase {
|
|||
BootResult result = tryBootVm(TAG, "test_vm_boot_time");
|
||||
assertThat(result.payloadStarted).isTrue();
|
||||
|
||||
final Double nanoToMilli = 1000000.0;
|
||||
final double nanoToMilli = 1000000.0;
|
||||
vmStartingTimeMetrics.add(result.getVMStartingElapsedNanoTime() / nanoToMilli);
|
||||
bootTimeMetrics.add(result.endToEndNanoTime / nanoToMilli);
|
||||
bootloaderTimeMetrics.add(result.getBootloaderElapsedNanoTime() / nanoToMilli);
|
||||
kernelBootTimeMetrics.add(result.getKernelElapsedNanoTime() / nanoToMilli);
|
||||
userspaceBootTimeMetrics.add(result.getUserspaceElapsedNanoTime() / nanoToMilli);
|
||||
}
|
||||
|
||||
reportMetrics(vmStartingTimeMetrics, "avf_perf/microdroid/vm_starting_time_", "_ms");
|
||||
reportMetrics(bootTimeMetrics, "avf_perf/microdroid/boot_time_", "_ms");
|
||||
reportMetrics(bootloaderTimeMetrics, "avf_perf/microdroid/bootloader_time_", "_ms");
|
||||
reportMetrics(kernelBootTimeMetrics, "avf_perf/microdroid/kernel_boot_time_", "_ms");
|
||||
|
|
|
@ -234,6 +234,7 @@ public abstract class MicrodroidDeviceTestBase {
|
|||
public static class BootResult {
|
||||
public final boolean payloadStarted;
|
||||
public final int deathReason;
|
||||
public final long apiCallNanoTime;
|
||||
public final long endToEndNanoTime;
|
||||
|
||||
public final OptionalLong vcpuStartedNanoTime;
|
||||
|
@ -243,11 +244,13 @@ public abstract class MicrodroidDeviceTestBase {
|
|||
|
||||
BootResult(boolean payloadStarted,
|
||||
int deathReason,
|
||||
long apiCallNanoTime,
|
||||
long endToEndNanoTime,
|
||||
OptionalLong vcpuStartedNanoTime,
|
||||
OptionalLong kernelStartedNanoTime,
|
||||
OptionalLong initStartedNanoTime,
|
||||
OptionalLong payloadStartedNanoTime) {
|
||||
this.apiCallNanoTime = apiCallNanoTime;
|
||||
this.payloadStarted = payloadStarted;
|
||||
this.deathReason = deathReason;
|
||||
this.endToEndNanoTime = endToEndNanoTime;
|
||||
|
@ -273,6 +276,10 @@ public abstract class MicrodroidDeviceTestBase {
|
|||
return payloadStartedNanoTime.getAsLong();
|
||||
}
|
||||
|
||||
public long getVMStartingElapsedNanoTime() {
|
||||
return getVcpuStartedNanoTime() - apiCallNanoTime;
|
||||
}
|
||||
|
||||
public long getBootloaderElapsedNanoTime() {
|
||||
return getKernelStartedNanoTime() - getVcpuStartedNanoTime();
|
||||
}
|
||||
|
@ -307,12 +314,13 @@ public abstract class MicrodroidDeviceTestBase {
|
|||
super.onDied(vm, reason);
|
||||
}
|
||||
};
|
||||
long beginTime = System.nanoTime();
|
||||
long apiCallNanoTime = System.nanoTime();
|
||||
listener.runToFinish(logTag, vm);
|
||||
return new BootResult(
|
||||
payloadStarted.getNow(false),
|
||||
deathReason.getNow(DeathReason.INFRASTRUCTURE_ERROR),
|
||||
endTime.getNow(beginTime) - beginTime,
|
||||
apiCallNanoTime,
|
||||
endTime.getNow(apiCallNanoTime) - apiCallNanoTime,
|
||||
listener.getVcpuStartedNanoTime(),
|
||||
listener.getKernelStartedNanoTime(),
|
||||
listener.getInitStartedNanoTime(),
|
||||
|
|
Loading…
Reference in New Issue