Minecraft provides a Debug Profiler that provides system data, current game settings, JVM data, level data, and sided tick information to find time consuming code. Considering things like TickEvents and ticking BlockEntities, this can be very useful for modders and server owners that want to find a lag source.
== Using the Debug Profiler ==
The Debug Profiler is very simple to use. The keybind <code>F3 + L</code> can be used to start the profiler. After 10 seconds, the profiler will automatically stop; however, it can be stopped earlier by pressing the keybind again.
{{Tip/Important| The <code>/debug</code> still runs; however, no data will be dumped to any location.}}
{{Tip|You can only profile code paths that are actually being reached. Entities and Block Entities that you want to profile must exist in the level to show up in the results.}}
After the debugger has stopped, it will create a new zip within the <code>debug/profiling</code> subdirectory in your run directory. The file name will be formatted with the date and time as <code>yyyy-mm-dd_hh_mi_ss-WorldName-VersionNumber.zip</code>.
== Reading a Profiling result ==
Within each sided folder (<code>client</code> and <code>server</code>), you will find a <code>profiling.txt</code> file containing the result data. At the top, it first tells you how long in milliseconds it was running and how many ticks ran in that time.
Below that, you will find information similar to the snippet below:
Here is a small explanation of what each part means
{| class="wikitable"
! [02] !! tick !! 99.31% !! 95.81%
|-
| The Depth of the section || The Name of the Section || The percentage of time it took in relation to it’s parent. For Layer 0 it’s the percentage of the time a tick takes, while for Layer 1 it’s the percentage of the time its parent takes || The second Percentage tells you how much Time it took from the entire tick.
|-
|}
== Profiling your own code ==
The Debug Profiler has basic support for <code>Entity</code> and <code>BlockEntity</code>. If you would like to profile something else, you may need to manually create your sections like so:
<syntaxhighlight lang="java">
profiler.startSection("<a custom section name>");
// The code you want to profile
profiler.endSection(); // OR profier.endStartSection("<new section name>");
</syntaxhighlight>
You can obtain the the <code>ProfilerFiller</code> instance from a <code>Level</code>, <code>MinecraftServer</code>, or <code>Minecraft</code> instance. Now you just need to search the file for your section name.