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 nameSupplier); /** * End section */ void pop(); void popPush(String name); void popPush(Supplier nameSupplier); void markForCharting(MetricCategory category); default void incrementCounter(String entryId) { this.incrementCounter(entryId, 1); } void incrementCounter(String counterName, int increment); default void incrementCounter(Supplier entryIdSupplier) { this.incrementCounter(entryIdSupplier, 1); } void incrementCounter(Supplier counterNameSupplier, int increment); static ProfilerFiller tee(ProfilerFiller first, ProfilerFiller second) { if (first == InactiveProfiler.INSTANCE) { return second; } else { return second == InactiveProfiler.INSTANCE ? first : new ProfilerFiller() { @Override public void startTick() { first.startTick(); second.startTick(); } @Override public void endTick() { first.endTick(); second.endTick(); } @Override public void push(String name) { first.push(name); second.push(name); } @Override public void push(Supplier nameSupplier) { first.push(nameSupplier); second.push(nameSupplier); } @Override public void markForCharting(MetricCategory category) { first.markForCharting(category); second.markForCharting(category); } @Override public void pop() { first.pop(); second.pop(); } @Override public void popPush(String name) { first.popPush(name); second.popPush(name); } @Override public void popPush(Supplier nameSupplier) { first.popPush(nameSupplier); second.popPush(nameSupplier); } @Override public void incrementCounter(String counterName, int increment) { first.incrementCounter(counterName, increment); second.incrementCounter(counterName, increment); } @Override public void incrementCounter(Supplier counterNameSupplier, int increment) { first.incrementCounter(counterNameSupplier, increment); second.incrementCounter(counterNameSupplier, increment); } }; } } }