use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class CpuGaugeCollectorTest method testDoesntCollectAnyDataWhenInvalidValueForCpuClockTicksPerSecond.
@Test
public void testDoesntCollectAnyDataWhenInvalidValueForCpuClockTicksPerSecond() {
final long invalidClockTicksPerSecond = -1;
testGaugeCollector = new CpuGaugeCollector(fakeScheduledExecutorService, fakeProcFile, invalidClockTicksPerSecond);
testGaugeCollector.startCollecting(100, new Timer());
assertThat(fakeScheduledExecutorService.isEmpty()).isTrue();
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class MemoryGaugeCollectorTest method testStopCollecting_cancelsFutureTasks.
@Test
public void testStopCollecting_cancelsFutureTasks() {
testGaugeCollector.startCollecting(/* memoryMetricCollectionRateMs= */
500, new Timer());
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(0);
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(500);
assertThat(fakeScheduledExecutorService.isEmpty()).isFalse();
testGaugeCollector.stopCollecting();
assertThat(fakeScheduledExecutorService.isEmpty()).isTrue();
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class MemoryGaugeCollectorTest method testCollectedMemoryMetric_containsApproximatelyCorrectTimestamp.
@Test
public void testCollectedMemoryMetric_containsApproximatelyCorrectTimestamp() {
Timer testTimer = new Timer();
testGaugeCollector.startCollecting(/* memoryMetricCollectionRateMs= */
100, testTimer);
long beforeTimestampUs = testTimer.getCurrentTimestampMicros();
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
long afterTimestampUs = testTimer.getCurrentTimestampMicros();
AndroidMemoryReading metricReading = testGaugeCollector.memoryMetricReadings.poll();
assertThat(metricReading.getClientTimeUs()).isAtLeast(beforeTimestampUs);
assertThat(metricReading.getClientTimeUs()).isAtMost(afterTimestampUs);
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class MemoryGaugeCollectorTest method testStartCollecting_hasCorrectInterval.
@Test
public void testStartCollecting_hasCorrectInterval() {
testGaugeCollector.startCollecting(/* memoryMetricCollectionRateMs= */
500, new Timer());
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(0);
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(500);
testGaugeCollector.collectOnce(new Timer());
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(0);
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(500);
testGaugeCollector.startCollecting(/* memoryMetricCollectionRateMs= */
200, new Timer());
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(0);
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(200);
testGaugeCollector.collectOnce(new Timer());
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(0);
fakeScheduledExecutorService.simulateSleepExecutingAtMostOneTask();
assertThat(fakeScheduledExecutorService.getDelayToNextTask(TimeUnit.MILLISECONDS)).isEqualTo(200);
}
use of com.google.firebase.perf.util.Timer in project firebase-android-sdk by firebase.
the class MemoryGaugeCollectorTest method testCollectMemoryMetric_doesNotStartCollecting_withInvalidMemoryMetricCollectionRate.
@Test
public void testCollectMemoryMetric_doesNotStartCollecting_withInvalidMemoryMetricCollectionRate() {
testGaugeCollector.startCollecting(/* memoryMetricCollectionRateMs= */
-1, new Timer());
assertThat(fakeScheduledExecutorService.isEmpty()).isTrue();
testGaugeCollector.startCollecting(/* memoryMetricCollectionRateMs= */
0, new Timer());
assertThat(fakeScheduledExecutorService.isEmpty()).isTrue();
}
Aggregations