GameLoadTimesEvent.java
net.minecraft.client.telemetry.events.GameLoadTimesEvent
信息
- 全限定名:net.minecraft.client.telemetry.events.GameLoadTimesEvent
- 类型:public class
- 包:net.minecraft.client.telemetry.events
- 源码路径:src/main/java/net/minecraft/client/telemetry/events/GameLoadTimesEvent.java
- 起始行号:L20
- 职责:
TODO
字段/常量
-
INSTANCE- 类型:
GameLoadTimesEvent - 修饰符:
public static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
-
timeSource- 类型:
Ticker - 修饰符:
private final - 源码定位:
L23 - 说明:
TODO
- 类型:
-
measurements- 类型:
Map<TelemetryProperty<GameLoadTimesEvent.Measurement>,Stopwatch> - 修饰符:
private final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
bootstrapTime- 类型:
OptionalLong - 修饰符:
private - 源码定位:
L25 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.telemetry.events.GameLoadTimesEvent.Measurement- 类型:
record - 修饰符:
public - 源码定位:
L89 - 说明:
TODO
- 类型:
构造器
protected GameLoadTimesEvent(Ticker timeSource) @ L27
- 构造器名:GameLoadTimesEvent
- 源码定位:L27
- 修饰符:protected
参数:
- timeSource: Ticker
说明:
TODO
方法
下面的方法块按源码顺序生成。
public synchronized void beginStep(TelemetryProperty<GameLoadTimesEvent.Measurement> property) @ L31
- 方法名:beginStep
- 源码定位:L31
- 返回类型:void
- 修饰符:public synchronized
参数:
- property: TelemetryProperty<GameLoadTimesEvent.Measurement>
说明:
TODO
public synchronized void beginStep(TelemetryProperty<GameLoadTimesEvent.Measurement> property, Stopwatch measurement) @ L35
- 方法名:beginStep
- 源码定位:L35
- 返回类型:void
- 修饰符:public synchronized
参数:
- property: TelemetryProperty<GameLoadTimesEvent.Measurement>
- measurement: Stopwatch
说明:
TODO
private synchronized void beginStep(TelemetryProperty<GameLoadTimesEvent.Measurement> property, Function<TelemetryProperty<GameLoadTimesEvent.Measurement>,Stopwatch> measurement) @ L39
- 方法名:beginStep
- 源码定位:L39
- 返回类型:void
- 修饰符:private synchronized
参数:
- property: TelemetryProperty<GameLoadTimesEvent.Measurement>
- measurement: Function<TelemetryProperty<GameLoadTimesEvent.Measurement>,Stopwatch>
说明:
TODO
public synchronized void endStep(TelemetryProperty<GameLoadTimesEvent.Measurement> property) @ L45
- 方法名:endStep
- 源码定位:L45
- 返回类型:void
- 修饰符:public synchronized
参数:
- property: TelemetryProperty<GameLoadTimesEvent.Measurement>
说明:
TODO
public void send(TelemetryEventSender eventSender) @ L56
- 方法名:send
- 源码定位:L56
- 返回类型:void
- 修饰符:public
参数:
- eventSender: TelemetryEventSender
说明:
TODO
public synchronized void setBootstrapTime(long duration) @ L84
- 方法名:setBootstrapTime
- 源码定位:L84
- 返回类型:void
- 修饰符:public synchronized
参数:
- duration: long
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class GameLoadTimesEvent {
public static final GameLoadTimesEvent INSTANCE = new GameLoadTimesEvent(Ticker.systemTicker());
private static final Logger LOGGER = LogUtils.getLogger();
private final Ticker timeSource;
private final Map<TelemetryProperty<GameLoadTimesEvent.Measurement>, Stopwatch> measurements = new HashMap<>();
private OptionalLong bootstrapTime = OptionalLong.empty();
protected GameLoadTimesEvent(Ticker timeSource) {
this.timeSource = timeSource;
}
public synchronized void beginStep(TelemetryProperty<GameLoadTimesEvent.Measurement> property) {
this.beginStep(property, p -> Stopwatch.createStarted(this.timeSource));
}
public synchronized void beginStep(TelemetryProperty<GameLoadTimesEvent.Measurement> property, Stopwatch measurement) {
this.beginStep(property, p -> measurement);
}
private synchronized void beginStep(
TelemetryProperty<GameLoadTimesEvent.Measurement> property, Function<TelemetryProperty<GameLoadTimesEvent.Measurement>, Stopwatch> measurement
) {
this.measurements.computeIfAbsent(property, measurement);
}
public synchronized void endStep(TelemetryProperty<GameLoadTimesEvent.Measurement> property) {
Stopwatch stepMeasurement = this.measurements.get(property);
if (stepMeasurement == null) {
LOGGER.warn("Attempted to end step for {} before starting it", property.id());
} else {
if (stepMeasurement.isRunning()) {
stepMeasurement.stop();
}
}
}
public void send(TelemetryEventSender eventSender) {
eventSender.send(
TelemetryEventType.GAME_LOAD_TIMES,
properties -> {
synchronized (this) {
this.measurements
.forEach(
(key, stepMeasurement) -> {
if (!stepMeasurement.isRunning()) {
long elapsed = stepMeasurement.elapsed(TimeUnit.MILLISECONDS);
properties.put((TelemetryProperty<GameLoadTimesEvent.Measurement>)key, new GameLoadTimesEvent.Measurement((int)elapsed));
} else {
LOGGER.warn(
"Measurement {} was discarded since it was still ongoing when the event {} was sent.",
key.id(),
TelemetryEventType.GAME_LOAD_TIMES.id()
);
}
}
);
this.bootstrapTime
.ifPresent(duration -> properties.put(TelemetryProperty.LOAD_TIME_BOOTSTRAP_MS, new GameLoadTimesEvent.Measurement((int)duration)));
this.measurements.clear();
}
}
);
}
public synchronized void setBootstrapTime(long duration) {
this.bootstrapTime = OptionalLong.of(duration);
}
@OnlyIn(Dist.CLIENT)
public record Measurement(int millis) {
public static final Codec<GameLoadTimesEvent.Measurement> CODEC = Codec.INT.xmap(GameLoadTimesEvent.Measurement::new, o -> o.millis);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数/字段/方法调用 - 关联成员:
Stopwatch.createStarted()
- 引用位置: