Package io.airlift.testing

Examples of io.airlift.testing.TestingTicker.increment()


        {
            @Override
            public Response apply(Request input)
            {
                Duration delta = tickerIncrement.get();
                ticker.increment(delta.toMillis(), TimeUnit.MILLISECONDS);
                throw new RuntimeException("Foo");
            }
        };

        CyclicBarrier requestComplete = new CyclicBarrier(2);
View Full Code Here


        {
            @Override
            public Response apply(Request input)
            {
                Duration delta = tickerIncrement.get();
                ticker.increment(delta.toMillis(), TimeUnit.MILLISECONDS);
                throw new RuntimeException("Foo");
            }
        };

        CyclicBarrier requestComplete = new CyclicBarrier(2);
View Full Code Here

        {
            @Override
            public Response apply(Request input)
            {
                Duration delta = tickerIncrement.get();
                ticker.increment(delta.toMillis(), TimeUnit.MILLISECONDS);
                throw new RuntimeException("Foo");
            }
        };

        CyclicBarrier requestComplete = new CyclicBarrier(2);
View Full Code Here

    {
        TestingTicker ticker = new TestingTicker();

        DecayCounter counter = new DecayCounter(ExponentialDecay.oneMinute(), ticker);
        counter.add(1);
        ticker.increment(1, TimeUnit.MINUTES);

        assertTrue(Math.abs(counter.getCount() - 1 / Math.E) < 1e-9);
    }

    @Test
View Full Code Here

    {
        TestingTicker ticker = new TestingTicker();

        DecayCounter counter = new DecayCounter(ExponentialDecay.oneMinute(), ticker);
        counter.add(1);
        ticker.increment(1, TimeUnit.MINUTES);
        counter.add(2);

        double expected = 2 + 1 / Math.E;
        assertTrue(Math.abs(counter.getCount() - expected) < 1e-9);
    }
View Full Code Here

        // should have no compressions with so few values and the allowed error
        assertEquals(digest.getCompressions(), 0);
        assertEquals(digest.getConfidenceFactor(), 0.0);

        ticker.increment(60, TimeUnit.SECONDS);
        addAll(digest, asList(10, 11, 12, 13, 14, 15, 16, 17, 18, 19));

        // Considering that the first 10 values now have a weight of 0.5 per the alpha factor, they only contributed a count
        // of 5 to rank computations. Therefore, the 50th percentile is equivalent to a weighted rank of (5 + 10) / 2 = 7.5,
        // which corresponds to value 12
View Full Code Here

        // should have no compressions with so few values and the allowed error
        assertEquals(digest.getCompressions(), 0);
        assertEquals(digest.getConfidenceFactor(), 0.0);

        ticker.increment(60, TimeUnit.SECONDS);
        addAll(digest, asList(10, 11, 12, 13, 14, 15, 16, 17, 18, 19));

        // The first 10 values only contribute 5 to the counts per the alpha factor
        assertEquals(
                digest.getHistogram(asList(10L, 20L)),
View Full Code Here

        TestingTicker ticker = new TestingTicker();
        QuantileDigest digest = new QuantileDigest(1,
                ExponentialDecay.computeAlpha(0.5, targetAgeInSeconds), ticker, false);

        addAll(digest, asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
        ticker.increment(targetAgeInSeconds, TimeUnit.SECONDS);
        addAll(digest, asList(10, 11, 12, 13, 14, 15, 16, 17, 18, 19));

        // The first 10 values only contribute 5 to the counts per the alpha factor
        assertEquals(
                digest.getHistogram(asList(10L, 20L)),
View Full Code Here

        QuantileDigest digest = new QuantileDigest(0.01,
                ExponentialDecay.computeAlpha(QuantileDigest.ZERO_WEIGHT_THRESHOLD, 60), ticker, false);

        addRange(digest, 1, 10);

        ticker.increment(1000, TimeUnit.SECONDS); // TODO: tighter bounds?

        int from = 4;
        int to = 7;
        addRange(digest, from, to + 1);
View Full Code Here

        for (int i = 0; i < 10; ++i) {
            digest.add(i);
            digest.validate();

            // bump the clock to make all previous values decay to ~0
            ticker.increment(targetAgeInSeconds, TimeUnit.SECONDS);
        }

        assertEquals(digest.getTotalNodeCount(), 1);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.