SingleTickProfiler.java
net.minecraft.util.profiling.SingleTickProfiler
信息
- 全限定名:net.minecraft.util.profiling.SingleTickProfiler
- 类型:public class
- 包:net.minecraft.util.profiling
- 源码路径:src/main/java/net/minecraft/util/profiling/SingleTickProfiler.java
- 起始行号:L11
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L12 - 说明:
TODO
- 类型:
-
realTime- 类型:
LongSupplier - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
saveThreshold- 类型:
long - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
tick- 类型:
int - 修饰符:
private - 源码定位:
L15 - 说明:
TODO
- 类型:
-
location- 类型:
File - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
profiler- 类型:
ProfileCollector - 修饰符:
private - 源码定位:
L17 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public SingleTickProfiler(LongSupplier realTime, String location, long saveThresholdNs) @ L19
- 构造器名:SingleTickProfiler
- 源码定位:L19
- 修饰符:public
参数:
- realTime: LongSupplier
- location: String
- saveThresholdNs: long
说明:
TODO
方法
下面的方法块按源码顺序生成。
public ProfilerFiller startTick() @ L25
- 方法名:startTick
- 源码定位:L25
- 返回类型:ProfilerFiller
- 修饰符:public
参数:
- 无
说明:
TODO
public void endTick() @ L31
- 方法名:endTick
- 源码定位:L31
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public static SingleTickProfiler createTickProfiler(String name) @ L43
- 方法名:createTickProfiler
- 源码定位:L43
- 返回类型:SingleTickProfiler
- 修饰符:public static
参数:
- name: String
说明:
TODO
public static ProfilerFiller decorateFiller(ProfilerFiller filler, SingleTickProfiler tickProfiler) @ L47
- 方法名:decorateFiller
- 源码定位:L47
- 返回类型:ProfilerFiller
- 修饰符:public static
参数:
- filler: ProfilerFiller
- tickProfiler: SingleTickProfiler
说明:
TODO
代码
public class SingleTickProfiler {
private static final Logger LOGGER = LogUtils.getLogger();
private final LongSupplier realTime;
private final long saveThreshold;
private int tick;
private final File location;
private ProfileCollector profiler = InactiveProfiler.INSTANCE;
public SingleTickProfiler(LongSupplier realTime, String location, long saveThresholdNs) {
this.realTime = realTime;
this.location = new File("debug", location);
this.saveThreshold = saveThresholdNs;
}
public ProfilerFiller startTick() {
this.profiler = new ActiveProfiler(this.realTime, () -> this.tick, () -> true);
this.tick++;
return this.profiler;
}
public void endTick() {
if (this.profiler != InactiveProfiler.INSTANCE) {
ProfileResults results = this.profiler.getResults();
this.profiler = InactiveProfiler.INSTANCE;
if (results.getNanoDuration() >= this.saveThreshold) {
File file = new File(this.location, "tick-results-" + Util.getFilenameFormattedDateTime() + ".txt");
results.saveResults(file.toPath());
LOGGER.info("Recorded long tick -- wrote info to: {}", file.getAbsolutePath());
}
}
}
public static @Nullable SingleTickProfiler createTickProfiler(String name) {
return SharedConstants.DEBUG_MONITOR_TICK_TIMES ? new SingleTickProfiler(Util.timeSource, name, SharedConstants.MAXIMUM_TICK_TIME_NANOS) : null;
}
public static ProfilerFiller decorateFiller(ProfilerFiller filler, @Nullable SingleTickProfiler tickProfiler) {
return tickProfiler != null ? ProfilerFiller.combine(tickProfiler.startTick(), filler) : filler;
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Util.getFilenameFormattedDateTime()
- 引用位置:
-
- 引用位置:
字段/构造调用 - 关联成员:
File()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
ActiveProfiler()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
参数/方法调用/返回值 - 关联成员:
ProfilerFiller.combine()
- 引用位置: