Examples of Histogram


Examples of com.alibaba.druid.util.Histogram

import com.alibaba.druid.util.Histogram;

public class HistogramTest extends TestCase {

    public void test_histo() throws Exception {
        Histogram histo = Histogram.makeHistogram(4);
       
        Assert.assertEquals(4, histo.getRanges().length);

        histo.record(0);
       
        histo.record(1);
        histo.record(2);
       
        histo.record(11);
        histo.record(12);
        histo.record(13);
       
        histo.record(101);
        histo.record(102);
        histo.record(103);
        histo.record(104);
       
        histo.record(1001);
        histo.record(1002);
        histo.record(1003);
        histo.record(1004);
        histo.record(1005);
       
        histo.record(10001);
       
        Assert.assertEquals(1, histo.get(0));
        Assert.assertEquals(2, histo.get(1));
        Assert.assertEquals(3, histo.get(2));
        Assert.assertEquals(4, histo.get(3));
        Assert.assertEquals(6, histo.get(4));
       
        histo.toString();
    }
View Full Code Here

Examples of com.codahale.metrics.Histogram

    public void testUpdateNoMetricYet() {

        final Map<String, Histogram> emptyMap = new HashMap<String, Histogram>();
        final SortedMap<String, Histogram> emptyMetricMap = ImmutableSortedMap.copyOf(emptyMap);
        when(mockMetricRegistry.getHistograms()).thenReturn(emptyMetricMap);
        final Histogram mockHistogram = mock(Histogram.class);
        when(mockHistogramBuilder.buildHistogram()).thenReturn(mockHistogram);

        metricReporter.update(METRIC_NAME, VALUE_1);

        verify(mockMetricRegistry).getHistograms();
View Full Code Here

Examples of com.codahale.metrics.Histogram

        verifyNoMoreInteractions(mockMetricRegistry, mockScheduledReporter, mockHistogramBuilder, mockHistogram);
    }

    @Test
    public void testUpdateMetricAlreadyPresent() {
        final Histogram mockHistogram = mock(Histogram.class);
        final Map<String, Histogram> map = new HashMap<String, Histogram>();
        map.put(METRIC_NAME, mockHistogram);
        final SortedMap<String, Histogram> metricMap = ImmutableSortedMap.copyOf(map);
        when(mockMetricRegistry.getHistograms()).thenReturn(metricMap);
View Full Code Here

Examples of com.codahale.metrics.Histogram

public class SlidingWindowHistogramBuilderTest {

    @Test
    public void testBuildHistogram() {
        final SlidingWindowHistogramBuilder histogramBuilder = new SlidingWindowHistogramBuilder(3000);
        final Histogram histogram1 = histogramBuilder.buildHistogram();
        assertNotNull(histogram1);
        final Histogram histogram2 = histogramBuilder.buildHistogram();
        assertNotNull(histogram2);
        assertNotSame(histogram1, histogram2);
    }
View Full Code Here

Examples of com.codahale.metrics.Histogram

public class SlidingTimeWindowHistogramBuilderTest {

    @Test
    public void testBuildHistogram() {
        final SlidingTimeWindowHistogramBuilder histogramBuilder = new SlidingTimeWindowHistogramBuilder(3000);
        final Histogram histogram1 = histogramBuilder.buildHistogram();
        assertNotNull(histogram1);
        final Histogram histogram2 = histogramBuilder.buildHistogram();
        assertNotNull(histogram2);
        assertNotSame(histogram1, histogram2);

    }
View Full Code Here

Examples of com.codahale.metrics.Histogram

public class ExponentiallyDecayingHistogramBuilderTest {

    @Test
    public void testBuildHistogramDefaultParams() {
        final ExponentiallyDecayingHistogramBuilder builder = new ExponentiallyDecayingHistogramBuilder();
        final Histogram histogram1 = builder.buildHistogram();
        assertNotNull(histogram1);
        final Histogram histogram2 = builder.buildHistogram();
        assertNotNull(histogram2);
        assertNotSame(histogram1, histogram2);
    }
View Full Code Here

Examples of com.codahale.metrics.Histogram

    }

    @Test
    public void testBuildHistogramSpecificParams() {
        final ExponentiallyDecayingHistogramBuilder builder = new ExponentiallyDecayingHistogramBuilder(1000, 0.5);
        final Histogram histogram1 = builder.buildHistogram();
        assertNotNull(histogram1);
        final Histogram histogram2 = builder.buildHistogram();
        assertNotNull(histogram2);
        assertNotSame(histogram1, histogram2);
    }
View Full Code Here

Examples of com.codahale.metrics.Histogram

public class UniformHistogramBuilderTest {

    @Test
    public void testBuildHistogramDefaultParams() {
        final UniformHistogramBuilder builder = new UniformHistogramBuilder();
        final Histogram histogram1 = builder.buildHistogram();
        assertNotNull(histogram1);
        final Histogram histogram2 = builder.buildHistogram();
        assertNotNull(histogram2);
        assertNotSame(histogram1, histogram2);
    }
View Full Code Here

Examples of com.codahale.metrics.Histogram

    }

    @Test
    public void testBuildHistogramCustomParams() {
        final UniformHistogramBuilder builder = new UniformHistogramBuilder(1024);
        final Histogram histogram1 = builder.buildHistogram();
        assertNotNull(histogram1);
        final Histogram histogram2 = builder.buildHistogram();
        assertNotNull(histogram2);
        assertNotSame(histogram1, histogram2);
    }
View Full Code Here

Examples of com.codahale.metrics.Histogram

        if (size == 0) {
            reservoir = new ExponentiallyDecayingReservoir();
        } else {
            reservoir = new ExponentiallyDecayingReservoir(size, alpha);
        }
        return new Histogram(reservoir);
    }
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.