Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e5f622c authored by Matías Hernández's avatar Matías Hernández Committed by Android (Google) Code Review
Browse files

Merge "Tweak RateEstimator's alpha value" into udc-qpr-dev

parents b9777bc4 d39cb044
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ package com.android.server.notification;
 * {@hide}
 */
class RateEstimator {
    private static final double RATE_ALPHA = 0.5;
    private static final double RATE_ALPHA = 0.7;
    private static final double MINIMUM_DT = 0.0005;

    private Long mLastEventTime;
+7 −7
Original line number Diff line number Diff line
@@ -138,22 +138,22 @@ public class RateEstimatorTest extends UiServiceTestCase {

    @Test
    public void testEstimateCatchesUpQuickly() {
        long nextEventTime = postEvents(mTestStartTime, 10, 20); // 20 events at 100Hz
        long nextEventTime = postEvents(mTestStartTime, 100, 30); // 30 events at 10Hz

        final float firstBurstRate = mEstimator.getRate(nextEventTime);
        assertThat(firstBurstRate).isWithin(10f).of(100);
        assertThat(firstBurstRate).isWithin(2f).of(10);

        nextEventTime += HOURS.toMillis(3); // 3 hours later...
        nextEventTime = postEvents(nextEventTime, 10, 20); // same burst of 20 events at 100Hz
        nextEventTime = postEvents(nextEventTime, 100, 30); // same burst of 30 events at 10Hz

        // Catching up. Rate is not yet 100, since we had a long period of inactivity...
        // Catching up. Rate is not yet 10, since we had a long period of inactivity...
        float secondBurstRate = mEstimator.getRate(nextEventTime);
        assertThat(secondBurstRate).isWithin(10f).of(60);
        assertThat(secondBurstRate).isWithin(1f).of(6);

        // ... but after a few more events, we are there.
        nextEventTime = postEvents(nextEventTime, 10, 10); // 10 more events at 100Hz
        nextEventTime = postEvents(nextEventTime, 100, 10); // 10 more events at 10Hz
        secondBurstRate = mEstimator.getRate(nextEventTime);
        assertThat(secondBurstRate).isWithin(10f).of(100);
        assertThat(secondBurstRate).isWithin(1f).of(10);
    }

    /** @return the next event time. */