hystrix 所用到的数学统计知识

◇◆丶佛笑我妖孽 提交于 2020-08-20 06:30:36

hystrix   会统计用户延迟,并且对其进行直方分布统计:

import org.HdrHistogram.Histogram;

import java.util.Random;

/**
 * @Classname Main
 * @Since 2020/7/3 17:55
 * @Created by lizhifeng
 * @Desc
 * @see
 */
public class Main {

    public static void main(String[] args) {

        Histogram histogram = new Histogram(3) ;

        for(int i = 1 ; i< 2000 ; i++ ) {
            histogram.recordValue(new Random().nextInt(1000));
        }

        for(int i = 1 ; i< 8000 ; i++ ) {
            histogram.recordValue(new Random().nextInt(100));
        }

        System.out.println(histogram.getMaxValue());
        System.out.println(histogram.getMean());
        System.out.println(histogram.getStdDeviation());

        System.out.println(histogram.getValueAtPercentile(90));
        
    }
}

 

最大值为999,平均值为 139.85, 方差为223, 90%的数据分布在0-502之间。

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!