Package com.jamieallen.sdisruptor.collections

Examples of com.jamieallen.sdisruptor.collections.Histogram


    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionWhenIntervalLessThanOrEqualToZero()
    {
        new Histogram(new long[]{-1, 10, 20});
    }
View Full Code Here


    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionWhenIntervalDoNotIncrease()
    {
        new Histogram(new long[]{1, 10, 10, 20});
    }
View Full Code Here

    }

    @Test
    public void shouldNotAddObservation()
    {
        Histogram histogram = new Histogram(new long[]{ 10, 20, 30 });
        assertFalse(histogram.addObservation(31));
    }
View Full Code Here

    @Test
    public void shouldAddObservations()
    {
        addObservations(histogram, 10L, 30L, 50L);

        Histogram histogram2 = new Histogram(INTERVALS);
        addObservations(histogram2, 10L, 20L, 25L);

        histogram.addObservations(histogram2);

        assertThat(Long.valueOf(6L), is(Long.valueOf(histogram.count())));
View Full Code Here

    }

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionWhenIntervalsDoNotMatch()
    {
        Histogram histogram2 = new Histogram(new long[]{ 1L, 2L, 3L});
        histogram.addObservations(histogram2);
    }
View Full Code Here

    @Test
    public void shouldGetMeanObservation()
    {
        final long[] INTERVALS = new long[]{ 1, 10, 100, 1000, 10000 };
        final Histogram histogram = new Histogram(INTERVALS);

        addObservations(histogram, 1L, 7L, 10L, 10L, 11L, 144L);

        assertThat(histogram.getMean(), is(new BigDecimal("32.67")));
    }
View Full Code Here

    @Test
    public void shouldCorrectMeanForSkewInTopAndBottomPopulatedIntervals()
    {
        final long[] INTERVALS = new long[]{ 100, 110, 120, 130, 140, 150, 1000, 10000 };
        final Histogram histogram = new Histogram(INTERVALS);

        for (long i = 100; i < 152; i++)
        {
            histogram.addObservation(i);
        }

        assertThat(histogram.getMean(), is(new BigDecimal("125.02")));
    }
View Full Code Here

    @Test
    public void shouldGetTwoNinesUpperBound()
    {
        final long[] INTERVALS = new long[]{ 1, 10, 100, 1000, 10000 };
        final Histogram histogram = new Histogram(INTERVALS);

        for (long i = 1; i < 101; i++)
        {
            histogram.addObservation(i);
        }

        assertThat(Long.valueOf(histogram.getTwoNinesUpperBound()), is(Long.valueOf(100L)));
    }
View Full Code Here

    @Test
    public void shouldGetFourNinesUpperBound()
    {
        final long[] INTERVALS = new long[]{ 1, 10, 100, 1000, 10000 };
        final Histogram histogram = new Histogram(INTERVALS);

        for (long i = 1; i < 102; i++)
        {
            histogram.addObservation(i);
        }

        assertThat(Long.valueOf(histogram.getFourNinesUpperBound()), is(Long.valueOf(1000L)));
    }
View Full Code Here

TOP

Related Classes of com.jamieallen.sdisruptor.collections.Histogram

Copyright © 2018 www.massapicom. 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.