You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.3 KiB
65 lines
1.3 KiB
package com.fr.design.carton.latency; |
|
|
|
/** |
|
* 卡顿等级 |
|
* |
|
* @author Levy.Xie |
|
* @since 11.0 |
|
* Created on 2024/07/01 |
|
*/ |
|
public enum LatencyLevel { |
|
|
|
// 非常流畅 |
|
FLASH(0, 50, "waitNum1"), |
|
// 流畅 |
|
SMOOTH(50, 100, "waitNum2"), |
|
// 轻微卡顿 |
|
SLIGHT(100, 200, "waitNum3"), |
|
// 中等卡顿 |
|
MILD(200, 500, "waitNum4"), |
|
// 明显卡顿 |
|
NOTICEABLE(500, 1000, "waitNum5"), |
|
// 严重卡顿 |
|
SERVE(1000, 2000, "waitNum6"), |
|
// 非常严重卡顿 |
|
EXTREME(2000, 3000, "waitNum7"), |
|
// 极度卡顿 |
|
CRITICAL(3000, Long.MAX_VALUE, "waitNum8"); |
|
|
|
final long start; |
|
final long end; |
|
final String mark; |
|
|
|
LatencyLevel(long start, long end, String mark) { |
|
this.start = start; |
|
this.end = end; |
|
this.mark = mark; |
|
} |
|
|
|
public long getStart() { |
|
return start; |
|
} |
|
|
|
public long getEnd() { |
|
return end; |
|
} |
|
|
|
public String getMark() { |
|
return mark; |
|
} |
|
|
|
/** |
|
* 评估当前卡顿等级 |
|
* |
|
* @param cost UI-EventQueue响应耗时 |
|
* @return 卡顿等级 |
|
*/ |
|
public static LatencyLevel measure(long cost) { |
|
for (LatencyLevel level : LatencyLevel.values()) { |
|
if (cost >= level.getStart() && cost < level.getEnd()) { |
|
return level; |
|
} |
|
} |
|
return CRITICAL; |
|
} |
|
}
|
|
|