性能指标的含义:
常见的性能指标:TP50、TP90、TP99、TP999
解释:TP表示Top Percentile Top百分数,是统计学的术语。与平均数、中位数一类的概念。
简单理解:TP 100ms 99%的查询都在100ms内返回
计算方式:拿100次调用的耗时,排序,取第99个的耗时,这就是TP99的值;
private void calTime(List<Long> timeList) {
timeList.sort(Long::compareTo);
double tp50 = timeList.size() * 0.5;
double tp90 = timeList.size() * 0.9;
double tp99 = timeList.size() * 0.99;
double tp999 = timeList.size() * 0.999;
// Math.ceil() 向上取整
System.out.println("tp50:" + timeList.get((int) Math.ceil(tp50)));
System.out.println("tp90:" + timeList.get((int) Math.ceil(tp90)));
System.out.println("tp99:" + timeList.get((int) Math.ceil(tp99)));
System.out.println("tp999:" + timeList.get((int) Math.ceil(tp999)));
}