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

Commit b80d30d8 authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Improve the performance tests.

The original tests would only run 5 iterations per test.

Test: unit test
Change-Id: I221129b44e81d4b8dc7151185104af8515a04b29
parent f3a5834b
Loading
Loading
Loading
Loading
+11 −19
Original line number Diff line number Diff line
@@ -58,38 +58,30 @@ public class BinderCallsStatsPerfTest {
    @Test
    public void timeCallSession() {
        mBinderCallsStats.setDetailedTracking(true);
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        Binder b = new Binder();
        int i = 0;
        while (state.keepRunning()) {
            CallSession s = mBinderCallsStats.callStarted(b, i % 100);
            mBinderCallsStats.callEnded(s, 0, 0);
            i++;
        }
        runScenario();
    }

    @Test
    public void timeCallSessionOnePercentSampling() {
        mBinderCallsStats.setDetailedTracking(false);
        mBinderCallsStats.setSamplingInterval(100);
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        Binder b = new Binder();
        int i = 0;
        while (state.keepRunning()) {
            CallSession s = mBinderCallsStats.callStarted(b, i % 100);
            mBinderCallsStats.callEnded(s, 0, 0);
            i++;
        }
        runScenario();
    }

    @Test
    public void timeCallSessionTrackingDisabled() {
        mBinderCallsStats.setDetailedTracking(false);
        runScenario();
    }

    private void runScenario() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        Binder b = new Binder();
        while (state.keepRunning()) {
            CallSession s = mBinderCallsStats.callStarted(b, 0);
            for (int i = 0; i < 1000; i++) {
                CallSession s = mBinderCallsStats.callStarted(b, i % 100);
                mBinderCallsStats.callEnded(s, 0, 0);
            }
        }

    }
}