Terra (Fabric/Forge/Paper)

Terra (Fabric/Forge/Paper)

74.2k Downloads

Improve profiler (stack-based profiler)

dfsek opened this issue ยท 2 comments

commented

Redo the included profiler to use a stack-based profiling approach. Pseudocode example:

profiler.push("a");
doSomething();
doAnotherThing();
profiler.pop("a");

doSomething() {
  profiler.push("b");
  doTheThing();
  profiler.pop("b");
}

doAnotherThing() {
  profiler.push("c");
  doTheOtherThing();
  profiler.pop("c");
}

Output:

a - #.## ms avg, #.## ms min, #.## ms max, #.## ms total, #.## ms std. dev
  b - #.## ms avg, #.## ms min, #.## ms max, #.## ms total, #.## ms std. dev (##.## % of a)
  c - #.## ms avg, #.## ms min, #.## ms max, #.## ms total, #.## ms std. dev (##.## % of a)

This would allow seeing exactly how long certain things and subsections of those things take, while also being easily readable, allowing config pack devs to know what things are taking the most time. With this, we could even separately profile specific TerraScripts, and it would generate a tree graph of all sub-scripts invoked and exactly how long they took.

commented

This would also enable addons to easily add profiling for things they do. We should add a TerraPlugin#getProfiler method for ease of access to the profiler for internal use and addons.

commented

Smth like this would work nicely with a kotlin DSL too