Changes

155 bytes removed ,  17:50, 20 December 2020
add under construction template, use tip templates
Line 1: Line 1:  +
{{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 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.
    
== Using the Debug Profiler ==
 
== Using the Debug Profiler ==
   −
The Debug Profiler is very simple to use. It requires two commands <code><nowiki>/debug start</nowiki></code>, which starts the profiling process, and <code><nowiki>/debug stop</nowiki></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. 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.
   −
{{Colored box|title=Tip|content=Naturally, you can only profile code paths that are actually being reached. Entities and TileEntities that you want to profile must exist in the world to show up in the results.}}
+
{{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.}}
   −
After you’ve stopped the debugger it will create a new file, it can be found within the <code><nowiki>debug</nowiki></code> subdirectory in your run directory. The file name will be formatted with the date and time as <code><nowiki>profile-results-yyyy-mm-dd_hh.mi.ss.txt</nowiki></code>.
+
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>.
    
== Reading a Profiling result ==
 
== Reading a Profiling result ==
Line 29: Line 31:  
Here is a small explanation of what each part means
 
Here is a small explanation of what each part means
   −
{| class="wikitable sortable" border=1
+
{| class="wikitable"
! [02] !! tick !! 99.31% !! 95.81%
+
! [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.  
 
|  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.  
Line 38: Line 40:  
== Profiling your own code ==
 
== Profiling your own code ==
   −
The Debug Profiler has basic support for <code><nowiki>Entity</nowiki></code> and <code><nowiki>TileEntity</nowiki></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>TileEntity</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">
  Profiler#startSection(yourSectionName : String);
+
profiler.startSection("<a custom section name>");
  ''The code you want to profile
+
// The code you want to profile
  Profiler#endSection();
+
profiler.endSection(); // OR profier.endStartSection("<new section name>");
 
</syntaxhighlight>
 
</syntaxhighlight>
   −
You can obtain the the <code><nowiki>Profiler</nowiki></code> instance from a <code><nowiki>World</nowiki></code>, <code><nowiki>MinecraftServer</nowiki></code>, or <code><nowiki>Minecraft</nowiki></code> instance. Now you just need to search the File for your section name.
+
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.
297

edits