minecraft-src/net/minecraft/util/profiling/ProfilerFiller.java
2025-07-04 02:00:41 +03:00

159 lines
3.5 KiB
Java

package net.minecraft.util.profiling;
import java.util.function.Supplier;
import net.minecraft.util.profiling.metrics.MetricCategory;
public interface ProfilerFiller {
String ROOT = "root";
void startTick();
void endTick();
/**
* Start section
*/
void push(String name);
void push(Supplier<String> nameSupplier);
/**
* End section
*/
void pop();
void popPush(String name);
void popPush(Supplier<String> nameSupplier);
default void addZoneText(String string) {
}
default void addZoneValue(long l) {
}
default void setZoneColor(int i) {
}
default Zone zone(String string) {
this.push(string);
return new Zone(this);
}
default Zone zone(Supplier<String> supplier) {
this.push(supplier);
return new Zone(this);
}
void markForCharting(MetricCategory category);
default void incrementCounter(String entryId) {
this.incrementCounter(entryId, 1);
}
void incrementCounter(String counterName, int increment);
default void incrementCounter(Supplier<String> entryIdSupplier) {
this.incrementCounter(entryIdSupplier, 1);
}
void incrementCounter(Supplier<String> counterNameSupplier, int increment);
static ProfilerFiller combine(ProfilerFiller profilerFiller, ProfilerFiller profilerFiller2) {
if (profilerFiller == InactiveProfiler.INSTANCE) {
return profilerFiller2;
} else {
return (ProfilerFiller)(profilerFiller2 == InactiveProfiler.INSTANCE
? profilerFiller
: new ProfilerFiller.CombinedProfileFiller(profilerFiller, profilerFiller2));
}
}
public static class CombinedProfileFiller implements ProfilerFiller {
private final ProfilerFiller first;
private final ProfilerFiller second;
public CombinedProfileFiller(ProfilerFiller profilerFiller, ProfilerFiller profilerFiller2) {
this.first = profilerFiller;
this.second = profilerFiller2;
}
@Override
public void startTick() {
this.first.startTick();
this.second.startTick();
}
@Override
public void endTick() {
this.first.endTick();
this.second.endTick();
}
@Override
public void push(String name) {
this.first.push(name);
this.second.push(name);
}
@Override
public void push(Supplier<String> nameSupplier) {
this.first.push(nameSupplier);
this.second.push(nameSupplier);
}
@Override
public void markForCharting(MetricCategory category) {
this.first.markForCharting(category);
this.second.markForCharting(category);
}
@Override
public void pop() {
this.first.pop();
this.second.pop();
}
@Override
public void popPush(String name) {
this.first.popPush(name);
this.second.popPush(name);
}
@Override
public void popPush(Supplier<String> nameSupplier) {
this.first.popPush(nameSupplier);
this.second.popPush(nameSupplier);
}
@Override
public void incrementCounter(String counterName, int increment) {
this.first.incrementCounter(counterName, increment);
this.second.incrementCounter(counterName, increment);
}
@Override
public void incrementCounter(Supplier<String> counterNameSupplier, int increment) {
this.first.incrementCounter(counterNameSupplier, increment);
this.second.incrementCounter(counterNameSupplier, increment);
}
@Override
public void addZoneText(String string) {
this.first.addZoneText(string);
this.second.addZoneText(string);
}
@Override
public void addZoneValue(long l) {
this.first.addZoneValue(l);
this.second.addZoneValue(l);
}
@Override
public void setZoneColor(int i) {
this.first.setZoneColor(i);
this.second.setZoneColor(i);
}
}
}