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.
The Debug Profiler is very simple to use. It requires the debug keybind
F3 + L to start the profiler. After 10 seconds, it will automatically stop; however, it can be stopped earlier by pressing the keybind again.
Naturally, you can only profile code paths that are actually being reached.
BlockEntities that you want to profile must exist in the level to show up in the results.
After you have stopped the debugger, it will create a new zip within the
debug/profiling subdirectory in your run directory.
The file name will be formatted with the date and time as
Within each sided folder (
server), you will find a
profiling.txt 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
 levels - 96.70%/96.70%  | Level Name - 99.76%/96.47%  | | tick - 99.31%/95.81%  | | | entities - 47.72%/45.72%  | | | | regular - 98.32%/44.95%  | | | | blockEntities - 0.90%/0.41%  | | | | | unspecified - 64.26%/0.26%  | | | | | minecraft:furnace - 33.35%/0.14%  | | | | | minecraft:chest - 2.39%/0.01%
|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 is the percentage of the time a tick takes. For Layer 1, it is the percentage of the time its parent takes.||The second percentage tells you how much time it took from the entire tick.|
The Debug Profiler has basic support for
BlockEntity. If you would like to profile something else, you may need to manually create your sections like so:
You can obtain the
ProfilerFiller#push(yourSectionName : String); //The code you want to profile ProfilerFiller#pop();
ProfilerFillerinstance from a
Minecraftinstance. Now you just need to search the results file for your section name.