| 1 | package net.minecraft.util.profiling;
|
| 2 |
|
| 3 | import java.util.function.Supplier;
|
| 4 | import net.minecraft.util.profiling.metrics.MetricCategory;
|
| 5 |
|
| 6 | public interface ProfilerFiller {
|
| 7 | String ROOT = "root";
|
| 8 |
|
| 9 | void startTick();
|
| 10 |
|
| 11 | void endTick();
|
| 12 |
|
| 13 | void push(String name);
|
| 14 |
|
| 15 | void push(Supplier<String> name);
|
| 16 |
|
| 17 | void pop();
|
| 18 |
|
| 19 | void popPush(String name);
|
| 20 |
|
| 21 | void popPush(Supplier<String> name);
|
| 22 |
|
| 23 | default void addZoneText(final String text) {
|
| 24 | }
|
| 25 |
|
| 26 | default void addZoneValue(final long value) {
|
| 27 | }
|
| 28 |
|
| 29 | default void setZoneColor(final int color) {
|
| 30 | }
|
| 31 |
|
| 32 | default Zone zone(final String name) {
|
| 33 | this.push(name);
|
| 34 | return new Zone(this);
|
| 35 | }
|
| 36 |
|
| 37 | default Zone zone(final Supplier<String> name) {
|
| 38 | this.push(name);
|
| 39 | return new Zone(this);
|
| 40 | }
|
| 41 |
|
| 42 | void markForCharting(MetricCategory category);
|
| 43 |
|
| 44 | default void incrementCounter(final String name) {
|
| 45 | this.incrementCounter(name, 1);
|
| 46 | }
|
| 47 |
|
| 48 | void incrementCounter(String name, int amount);
|
| 49 |
|
| 50 | default void incrementCounter(final Supplier<String> name) {
|
| 51 | this.incrementCounter(name, 1);
|
| 52 | }
|
| 53 |
|
| 54 | void incrementCounter(Supplier<String> name, int amount);
|
| 55 |
|
| 56 | static ProfilerFiller combine(final ProfilerFiller first, final ProfilerFiller second) {
|
| 57 | if (first == InactiveProfiler.INSTANCE) {
|
| 58 | return second;
|
| 59 | } else {
|
| 60 | return second == InactiveProfiler.INSTANCE ? first : new ProfilerFiller.CombinedProfileFiller(first, second);
|
| 61 | }
|
| 62 | }
|
| 63 |
|
| 64 | class CombinedProfileFiller implements ProfilerFiller {
|
| 65 | private final ProfilerFiller first;
|
| 66 | private final ProfilerFiller second;
|
| 67 |
|
| 68 | public CombinedProfileFiller(final ProfilerFiller first, final ProfilerFiller second) {
|
| 69 | this.first = first;
|
| 70 | this.second = second;
|
| 71 | }
|
| 72 |
|
| 73 | @Override
|
| 74 | public void startTick() {
|
| 75 | this.first.startTick();
|
| 76 | this.second.startTick();
|
| 77 | }
|
| 78 |
|
| 79 | @Override
|
| 80 | public void endTick() {
|
| 81 | this.first.endTick();
|
| 82 | this.second.endTick();
|
| 83 | }
|
| 84 |
|
| 85 | @Override
|
| 86 | public void push(final String name) {
|
| 87 | this.first.push(name);
|
| 88 | this.second.push(name);
|
| 89 | }
|
| 90 |
|
| 91 | @Override
|
| 92 | public void push(final Supplier<String> name) {
|
| 93 | this.first.push(name);
|
| 94 | this.second.push(name);
|
| 95 | }
|
| 96 |
|
| 97 | @Override
|
| 98 | public void markForCharting(final MetricCategory category) {
|
| 99 | this.first.markForCharting(category);
|
| 100 | this.second.markForCharting(category);
|
| 101 | }
|
| 102 |
|
| 103 | @Override
|
| 104 | public void pop() {
|
| 105 | this.first.pop();
|
| 106 | this.second.pop();
|
| 107 | }
|
| 108 |
|
| 109 | @Override
|
| 110 | public void popPush(final String name) {
|
| 111 | this.first.popPush(name);
|
| 112 | this.second.popPush(name);
|
| 113 | }
|
| 114 |
|
| 115 | @Override
|
| 116 | public void popPush(final Supplier<String> name) {
|
| 117 | this.first.popPush(name);
|
| 118 | this.second.popPush(name);
|
| 119 | }
|
| 120 |
|
| 121 | @Override
|
| 122 | public void incrementCounter(final String name, final int amount) {
|
| 123 | this.first.incrementCounter(name, amount);
|
| 124 | this.second.incrementCounter(name, amount);
|
| 125 | }
|
| 126 |
|
| 127 | @Override
|
| 128 | public void incrementCounter(final Supplier<String> name, final int amount) {
|
| 129 | this.first.incrementCounter(name, amount);
|
| 130 | this.second.incrementCounter(name, amount);
|
| 131 | }
|
| 132 |
|
| 133 | @Override
|
| 134 | public void addZoneText(final String text) {
|
| 135 | this.first.addZoneText(text);
|
| 136 | this.second.addZoneText(text);
|
| 137 | }
|
| 138 |
|
| 139 | @Override
|
| 140 | public void addZoneValue(final long value) {
|
| 141 | this.first.addZoneValue(value);
|
| 142 | this.second.addZoneValue(value);
|
| 143 | }
|
| 144 |
|
| 145 | @Override
|
| 146 | public void setZoneColor(final int color) {
|
| 147 | this.first.setZoneColor(color);
|
| 148 | this.second.setZoneColor(color);
|
| 149 | }
|
| 150 | }
|
| 151 | }
|
| 152 |
|