JvmProfiler.java

net.minecraft.util.profiling.jfr.JvmProfiler

信息

  • 全限定名:net.minecraft.util.profiling.jfr.JvmProfiler
  • 类型:public interface
  • 包:net.minecraft.util.profiling.jfr
  • 源码路径:src/main/java/net/minecraft/util/profiling/jfr/JvmProfiler.java
  • 起始行号:L20
  • 职责:

    TODO

字段/常量

  • INSTANCE
    • 类型: JvmProfiler
    • 修饰符: package-private
    • 源码定位: L21
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.util.profiling.jfr.JvmProfiler.NoOpProfiler
    • 类型: class
    • 修饰符: public static
    • 源码定位: L51
    • 说明:

      TODO

构造器

方法

下面的方法块按源码顺序生成。

boolean start(Environment environment) @ L25

  • 方法名:start
  • 源码定位:L25
  • 返回类型:boolean
  • 修饰符:package-private

参数:

  • environment: Environment

说明:

TODO

Path stop() @ L27

  • 方法名:stop
  • 源码定位:L27
  • 返回类型:Path
  • 修饰符:package-private

参数:

说明:

TODO

boolean isRunning() @ L29

  • 方法名:isRunning
  • 源码定位:L29
  • 返回类型:boolean
  • 修饰符:package-private

参数:

说明:

TODO

boolean isAvailable() @ L31

  • 方法名:isAvailable
  • 源码定位:L31
  • 返回类型:boolean
  • 修饰符:package-private

参数:

说明:

TODO

void onServerTick(float averageTickTime) @ L33

  • 方法名:onServerTick
  • 源码定位:L33
  • 返回类型:void
  • 修饰符:package-private

参数:

  • averageTickTime: float

说明:

TODO

void onClientTick(int fps) @ L35

  • 方法名:onClientTick
  • 源码定位:L35
  • 返回类型:void
  • 修饰符:package-private

参数:

  • fps: int

说明:

TODO

void onPacketReceived(ConnectionProtocol protocol, PacketType<?> packetId, SocketAddress remoteAddress, int readableBytes) @ L37

  • 方法名:onPacketReceived
  • 源码定位:L37
  • 返回类型:void
  • 修饰符:package-private

参数:

  • protocol: ConnectionProtocol
  • packetId: PacketType<?>
  • remoteAddress: SocketAddress
  • readableBytes: int

说明:

TODO

void onPacketSent(ConnectionProtocol protocol, PacketType<?> packetId, SocketAddress remoteAddress, int writtenBytes) @ L39

  • 方法名:onPacketSent
  • 源码定位:L39
  • 返回类型:void
  • 修饰符:package-private

参数:

  • protocol: ConnectionProtocol
  • packetId: PacketType<?>
  • remoteAddress: SocketAddress
  • writtenBytes: int

说明:

TODO

void onRegionFileRead(RegionStorageInfo info, ChunkPos pos, RegionFileVersion version, int readBytes) @ L41

  • 方法名:onRegionFileRead
  • 源码定位:L41
  • 返回类型:void
  • 修饰符:package-private

参数:

  • info: RegionStorageInfo
  • pos: ChunkPos
  • version: RegionFileVersion
  • readBytes: int

说明:

TODO

void onRegionFileWrite(RegionStorageInfo info, ChunkPos pos, RegionFileVersion version, int writtenBytes) @ L43

  • 方法名:onRegionFileWrite
  • 源码定位:L43
  • 返回类型:void
  • 修饰符:package-private

参数:

  • info: RegionStorageInfo
  • pos: ChunkPos
  • version: RegionFileVersion
  • writtenBytes: int

说明:

TODO

ProfiledDuration onWorldLoadedStarted() @ L45

  • 方法名:onWorldLoadedStarted
  • 源码定位:L45
  • 返回类型:ProfiledDuration
  • 修饰符:package-private

参数:

说明:

TODO

ProfiledDuration onChunkGenerate(ChunkPos pos, ResourceKey<Level> dimension, String name) @ L47

  • 方法名:onChunkGenerate
  • 源码定位:L47
  • 返回类型:ProfiledDuration
  • 修饰符:package-private

参数:

  • pos: ChunkPos
  • dimension: ResourceKey
  • name: String

说明:

TODO

ProfiledDuration onStructureGenerate(ChunkPos sourceChunkPos, ResourceKey<Level> dimension, Holder<Structure> structure) @ L49

  • 方法名:onStructureGenerate
  • 源码定位:L49
  • 返回类型:ProfiledDuration
  • 修饰符:package-private

参数:

  • sourceChunkPos: ChunkPos
  • dimension: ResourceKey
  • structure: Holder

说明:

TODO

代码

public interface JvmProfiler {
    JvmProfiler INSTANCE = (JvmProfiler)(Runtime.class.getModule().getLayer().findModule("jdk.jfr").isPresent() && FlightRecorder.isAvailable()
        ? JfrProfiler.getInstance()
        : new JvmProfiler.NoOpProfiler());
 
    boolean start(Environment environment);
 
    Path stop();
 
    boolean isRunning();
 
    boolean isAvailable();
 
    void onServerTick(float averageTickTime);
 
    void onClientTick(int fps);
 
    void onPacketReceived(final ConnectionProtocol protocol, final PacketType<?> packetId, final SocketAddress remoteAddress, final int readableBytes);
 
    void onPacketSent(final ConnectionProtocol protocol, final PacketType<?> packetId, final SocketAddress remoteAddress, final int writtenBytes);
 
    void onRegionFileRead(RegionStorageInfo info, ChunkPos pos, RegionFileVersion version, int readBytes);
 
    void onRegionFileWrite(RegionStorageInfo info, ChunkPos pos, RegionFileVersion version, int writtenBytes);
 
    @Nullable ProfiledDuration onWorldLoadedStarted();
 
    @Nullable ProfiledDuration onChunkGenerate(ChunkPos pos, ResourceKey<Level> dimension, String name);
 
    @Nullable ProfiledDuration onStructureGenerate(ChunkPos sourceChunkPos, ResourceKey<Level> dimension, Holder<Structure> structure);
 
    public static class NoOpProfiler implements JvmProfiler {
        private static final Logger LOGGER = LogUtils.getLogger();
        static final ProfiledDuration noOpCommit = ignored -> {};
 
        @Override
        public boolean start(Environment environment) {
            LOGGER.warn("Attempted to start Flight Recorder, but it's not supported on this JVM");
            return false;
        }
 
        @Override
        public Path stop() {
            throw new IllegalStateException("Attempted to stop Flight Recorder, but it's not supported on this JVM");
        }
 
        @Override
        public boolean isRunning() {
            return false;
        }
 
        @Override
        public boolean isAvailable() {
            return false;
        }
 
        @Override
        public void onPacketReceived(ConnectionProtocol protocol, PacketType<?> packetId, SocketAddress remoteAddress, int readableBytes) {
        }
 
        @Override
        public void onPacketSent(ConnectionProtocol protocol, PacketType<?> packetId, SocketAddress remoteAddress, int writtenBytes) {
        }
 
        @Override
        public void onRegionFileRead(RegionStorageInfo info, ChunkPos pos, RegionFileVersion version, int readBytes) {
        }
 
        @Override
        public void onRegionFileWrite(RegionStorageInfo info, ChunkPos pos, RegionFileVersion version, int writtenBytes) {
        }
 
        @Override
        public void onServerTick(float averageTickTime) {
        }
 
        @Override
        public void onClientTick(int fps) {
        }
 
        @Override
        public ProfiledDuration onWorldLoadedStarted() {
            return noOpCommit;
        }
 
        @Override
        public @Nullable ProfiledDuration onChunkGenerate(ChunkPos pos, ResourceKey<Level> dimension, String name) {
            return null;
        }
 
        @Override
        public ProfiledDuration onStructureGenerate(ChunkPos sourceChunkPos, ResourceKey<Level> dimension, Holder<Structure> structure) {
            return noOpCommit;
        }
    }
}

引用的其他类