@VisibleForTesting
    static long calculateProcessingTimeTimerInterval(long watermarkInterval, long idleTimeout) {
        checkArgument(watermarkInterval > 0 || idleTimeout > 0);
        if (watermarkInterval <= 0) {
            return idleTimeout;
        }
        if (idleTimeout <= 0) {
            return watermarkInterval;
        }

        long smallerInterval = Math.min(watermarkInterval, idleTimeout);
        long largerInterval = Math.max(watermarkInterval, idleTimeout);

        // If one of the intervals is 5x smaller, just pick the smaller one. The firing interval
        // for the smaller one this way will be perfectly accurate, while for the larger one it will
        // be good enough™. For example one timer is every 2s the other every 11s, the 2nd timer
        // will be effectively checked every 12s, which is an acceptable accuracy.
        long timerInterval;
        if (smallerInterval * 5 < largerInterval) {
            timerInterval = smallerInterval;
        } else {
            // Otherwise, just pick an interval 5x smaller than the smaller interval. Again accuracy
            // will be good enough™.
            timerInterval = smallerInterval / 5;
        }
        return Math.max(timerInterval, 1);
    }
@Test
    public void testCalculateProcessingTimeTimerInterval() {
        assertThat(calculateProcessingTimeTimerInterval(5, 0)).isEqualTo(5);
        assertThat(calculateProcessingTimeTimerInterval(5, -1)).isEqualTo(5);

        assertThat(calculateProcessingTimeTimerInterval(0, 5)).isEqualTo(5);
        assertThat(calculateProcessingTimeTimerInterval(-1, 5)).isEqualTo(5);

        assertThat(calculateProcessingTimeTimerInterval(5, 42)).isEqualTo(5);
        assertThat(calculateProcessingTimeTimerInterval(42, 5)).isEqualTo(5);

        assertThat(calculateProcessingTimeTimerInterval(2, 4)).isEqualTo(1);
        assertThat(calculateProcessingTimeTimerInterval(4, 2)).isEqualTo(1);

        assertThat(calculateProcessingTimeTimerInterval(100, 110)).isEqualTo(20);
        assertThat(calculateProcessingTimeTimerInterval(110, 100)).isEqualTo(20);
    }