Examples of TestingTicker


Examples of com.proofpoint.testing.TestingTicker

    @Test
    public void testRescaleWithDecayKeepsCompactTree()
            throws Exception
    {
        TestingTicker ticker = new TestingTicker();
        int targetAgeInSeconds = (int) (QuantileDigest.RESCALE_THRESHOLD_SECONDS);

        QuantileDigest digest = new QuantileDigest(0.01,
                ExponentialDecay.computeAlpha(QuantileDigest.ZERO_WEIGHT_THRESHOLD / 2, targetAgeInSeconds),
                ticker, true);

        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

Examples of com.proofpoint.testing.TestingTicker

            throws Exception
    {
        Duration warmupTime = new Duration(3, TimeUnit.SECONDS);
        Duration benchmarkTime = new Duration(5, TimeUnit.SECONDS);

        final QuantileDigest digest = new QuantileDigest(0.01, 0, new TestingTicker(), true);
        final Random random = new Random();

        Benchmark.Results results = Benchmark.run(new Runnable() {
            public void run()
            {
View Full Code Here

Examples of com.proofpoint.testing.TestingTicker

    @BeforeMethod
    public void setup()
    {
        bucketIdProvider = new TestingBucketIdProvider();
        ticker = new TestingTicker();
    }
View Full Code Here

Examples of com.proofpoint.testing.TestingTicker

public class TestDecayCounter
{
    @Test
    public void testCountDecays()
    {
        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);
    }
View Full Code Here

Examples of com.proofpoint.testing.TestingTicker

    }

    @Test
    public void testAddAfterRescale()
    {
        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

Examples of io.airlift.testing.TestingTicker

    @Test
    public void testExceptionFromResponseHandler()
            throws Exception
    {
        final TestingTicker ticker = new TestingTicker();
        final AtomicReference<Duration> tickerIncrement = new AtomicReference<>(new Duration(0, TimeUnit.SECONDS));

        Function<Request, Response> processor = new Function<Request, Response>()
        {
            @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

Examples of io.airlift.testing.TestingTicker

    @Test
    public void testExceptionFromResponseHandler()
            throws Exception
    {
        final TestingTicker ticker = new TestingTicker();
        final AtomicReference<Duration> tickerIncrement = new AtomicReference<>(new Duration(0, TimeUnit.SECONDS));

        Function<Request, Response> processor = new Function<Request, Response>()
        {
            @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

Examples of io.airlift.testing.TestingTicker

    @Test
    public void testExceptionFromResponseHandler()
            throws Exception
    {
        final TestingTicker ticker = new TestingTicker();
        final AtomicReference<Duration> tickerIncrement = new AtomicReference<>(new Duration(0, TimeUnit.SECONDS));

        Function<Request, Response> processor = new Function<Request, Response>()
        {
            @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

Examples of io.airlift.testing.TestingTicker

public class TestDecayCounter
{
    @Test
    public void testCountDecays()
    {
        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);
    }
View Full Code Here

Examples of io.airlift.testing.TestingTicker

    }

    @Test
    public void testAddAfterRescale()
    {
        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
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.