Changes

214 bytes added ,  22:26, 29 July 2021
Update debug profiler to 1.17, come back later to address new profiling information
Line 1: Line 1:  
{{Under construction}}
 
{{Under construction}}
   −
Minecraft provides a Debug Profiler that can be used to find time consuming code. Specially considering things like TickEvents and Ticking TileEntities this can be very useful for modders and server owners that want to find a lag source.
+
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 ==
 
== Using the Debug Profiler ==
   −
The Debug Profiler is very simple to use. It requires two commands <code>/debug start</code>, which starts the profiling process, and <code>/debug stop</code>, which ends it. The important part here is that the more time you give it to collect the data the better the results will be. It is recommended to at least let it collect data for a minute.
+
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|You can only profile code paths that are actually being reached. Entities and Tile Entities that you want to profile must exist in the world to show up in the results.}}
+
{{Tip/Important| The <code>/debug</code> still runs; however, no data will be dumped to any location.}}
   −
After you’ve stopped the debugger it will create a new file, it can be found within the <code>debug</code> subdirectory in your run directory. The file name will be formatted with the date and time as <code>profile-results-yyyy-mm-dd_hh.mi.ss.txt</code>.
+
{{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 ==
 
== Reading a Profiling result ==
   −
At the top it first tells you how long in milliseconds it was running and how many ticks ran in that time.
+
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:
 
Below that, you will find information similar to the snippet below:
Line 19: Line 21:  
<syntaxhighlight>
 
<syntaxhighlight>
 
[00] levels - 96.70%/96.70%
 
[00] levels - 96.70%/96.70%
[01] |  World Name - 99.76%/96.47%
+
[01] |  Level Name - 99.76%/96.47%
 
[02] |  |  tick - 99.31%/95.81%
 
[02] |  |  tick - 99.31%/95.81%
 
[03] |  |  |  entities - 47.72%/45.72%
 
[03] |  |  |  entities - 47.72%/45.72%
Line 40: Line 42:  
== Profiling your own code ==
 
== Profiling your own code ==
   −
The Debug Profiler has basic support for <code>Entity</code> and <code>TileEntity</code>. If you would like to profile something else, you may need to manually create your sections like so:
+
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">
 
<syntaxhighlight lang="java">
Line 48: Line 50:  
</syntaxhighlight>
 
</syntaxhighlight>
   −
You can obtain the the <code>Profiler</code> instance from a <code>World</code>, <code>MinecraftServer</code>, or <code>Minecraft</code> instance. Now you just need to search the file for your section name.
+
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.
       
[[Category:Beginner Topics]]
 
[[Category:Beginner Topics]]