mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-26 22:10:22 +00:00
improve data output
This commit is contained in:
1 parent
89267ce8cb
commit
7b3b341627
4 files changed
+10
-9
No files matched your search
@@ -12,6 +12,7 @@ import com.dfsek.terra.api.util.logging.Logger;
|
|||||||
import com.dfsek.terra.config.PluginConfig;
|
import com.dfsek.terra.config.PluginConfig;
|
||||||
import com.dfsek.terra.config.lang.Language;
|
import com.dfsek.terra.config.lang.Language;
|
||||||
import com.dfsek.terra.config.pack.ConfigPack;
|
import com.dfsek.terra.config.pack.ConfigPack;
|
||||||
|
import com.dfsek.terra.profiler.Profiler;
|
||||||
import com.dfsek.terra.world.TerraWorld;
|
import com.dfsek.terra.world.TerraWorld;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -64,4 +65,6 @@ public interface TerraPlugin extends LoaderRegistrar {
|
|||||||
default void runPossiblyUnsafeTask(Runnable task) {
|
default void runPossiblyUnsafeTask(Runnable task) {
|
||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Profiler getProfiler();
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,6 @@ import java.util.Map;
|
|||||||
public interface Profiler {
|
public interface Profiler {
|
||||||
ProfilerImpl INSTANCE = new ProfilerImpl();
|
ProfilerImpl INSTANCE = new ProfilerImpl();
|
||||||
|
|
||||||
static Profiler getInstance() {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void push(String frame);
|
void push(String frame);
|
||||||
|
|
||||||
void pop(String frame);
|
void pop(String frame);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class ProfilerImpl implements Profiler {
|
|||||||
private volatile boolean running = false;
|
private volatile boolean running = false;
|
||||||
|
|
||||||
|
|
||||||
protected ProfilerImpl() {
|
public ProfilerImpl() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,23 +34,25 @@ public class Timings {
|
|||||||
return subItems.computeIfAbsent(id, s -> new Timings());
|
return subItems.computeIfAbsent(id, s -> new Timings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(int indent) {
|
public String toString(int indent, Timings parent) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
builder.append("Avg ").append(average() / 1000000).append("ms");
|
builder.append((double) min() / 1000000).append("ms min / ").append(average() / 1000000).append("ms avg / ")
|
||||||
|
.append((double) max() / 1000000).append("ms max (").append(timings.size()).append(" samples, ")
|
||||||
|
.append((average() / parent.average()) * 100).append("% of parent)");
|
||||||
|
|
||||||
subItems.forEach((id, timings) -> {
|
subItems.forEach((id, timings) -> {
|
||||||
builder.append('\n');
|
builder.append('\n');
|
||||||
for(int i = 0; i <= indent; i++) {
|
for(int i = 0; i <= indent; i++) {
|
||||||
builder.append('\t');
|
builder.append('\t');
|
||||||
}
|
}
|
||||||
builder.append(id).append(": ").append(timings.toString(indent + 1));
|
builder.append(id).append(": ").append(timings.toString(indent + 1, this));
|
||||||
});
|
});
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toString(0);
|
return toString(0, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user