Search in sources :

Example 6 with GaugeMetadata

use of com.google.firebase.perf.v1.GaugeMetadata in project firebase-android-sdk by firebase.

the class FirebasePerfGaugeManagerValidatorTest method testGaugeMetadataWithoutMaxJavaHeapIsNotValid.

@Test
public void testGaugeMetadataWithoutMaxJavaHeapIsNotValid() {
    GaugeMetadata gaugeMetadata = GaugeMetadata.newBuilder().setProcessName("processName").setDeviceRamSizeKb(2000).setMaxEncouragedAppJavaHeapMemoryKb(800).build();
    GaugeMetric.Builder gaugeMetricBuilder = GaugeMetric.newBuilder();
    gaugeMetricBuilder.setSessionId("sessionId");
    gaugeMetricBuilder.setGaugeMetadata(gaugeMetadata);
    FirebasePerfGaugeMetricValidator validator = new FirebasePerfGaugeMetricValidator(gaugeMetricBuilder.build());
    assertThat(validator.isValidPerfMetric()).isFalse();
}
Also used : GaugeMetadata(com.google.firebase.perf.v1.GaugeMetadata) GaugeMetric(com.google.firebase.perf.v1.GaugeMetric) Test(org.junit.Test)

Example 7 with GaugeMetadata

use of com.google.firebase.perf.v1.GaugeMetadata in project firebase-android-sdk by firebase.

the class FirebasePerfGaugeManagerValidatorTest method testGaugeMetricIsValid.

@Test
public void testGaugeMetricIsValid() {
    // Construct a list of Cpu metric readings
    List<CpuMetricReading> expectedCpuMetricReadings = new ArrayList<>();
    expectedCpuMetricReadings.add(createValidCpuMetricReading(/* userTimeUs= */
    10, /* systemTimeUs= */
    20));
    expectedCpuMetricReadings.add(createValidCpuMetricReading(/* userTimeUs= */
    20, /* systemTimeUs= */
    30));
    // Construct a list of Memory metric readings
    List<AndroidMemoryReading> expectedMemoryMetricReadings = new ArrayList<>();
    expectedMemoryMetricReadings.add(createValidAndroidMetricReading(/* currentUsedAppJavaHeapMemoryKb= */
    1234));
    expectedMemoryMetricReadings.add(createValidAndroidMetricReading(/* currentUsedAppJavaHeapMemoryKb= */
    23456));
    // Construct GaugeMetadata
    GaugeMetadata gaugeMetadata = createValidGaugeMetadata("processName", /* deviceRamSizeKb= */
    2000, /* maxAppJavaHeapMemoryKb= */
    1000, /* maxEncouragedAppJavaHeapMemoryKb= */
    800);
    GaugeMetric.Builder gaugeMetricBuilder = GaugeMetric.newBuilder();
    gaugeMetricBuilder.setSessionId("sessionId");
    gaugeMetricBuilder.addAllCpuMetricReadings(expectedCpuMetricReadings);
    gaugeMetricBuilder.addAllAndroidMemoryReadings(expectedMemoryMetricReadings);
    gaugeMetricBuilder.setGaugeMetadata(gaugeMetadata);
    FirebasePerfGaugeMetricValidator validator = new FirebasePerfGaugeMetricValidator(gaugeMetricBuilder.build());
    assertThat(validator.isValidPerfMetric()).isTrue();
}
Also used : AndroidMemoryReading(com.google.firebase.perf.v1.AndroidMemoryReading) CpuMetricReading(com.google.firebase.perf.v1.CpuMetricReading) ArrayList(java.util.ArrayList) GaugeMetadata(com.google.firebase.perf.v1.GaugeMetadata) GaugeMetric(com.google.firebase.perf.v1.GaugeMetric) Test(org.junit.Test)

Aggregations

GaugeMetric (com.google.firebase.perf.v1.GaugeMetric)7 GaugeMetadata (com.google.firebase.perf.v1.GaugeMetadata)6 Test (org.junit.Test)6 Lazy (com.google.firebase.components.Lazy)1 AndroidMemoryReading (com.google.firebase.perf.v1.AndroidMemoryReading)1 ApplicationProcessState (com.google.firebase.perf.v1.ApplicationProcessState)1 CpuMetricReading (com.google.firebase.perf.v1.CpuMetricReading)1 PerfMetric (com.google.firebase.perf.v1.PerfMetric)1 ArrayList (java.util.ArrayList)1