Table of Content

What is profiling
Reason to profile
When to profile
Get profiler
Run profiler

What is profiling

Profiling is analysis and measuring for example the memory or time complexity of a program, the usage of particular instructions, or frequency and duration of function calls. The most common use of profiling information is to aid program optimization.

Sounds troublesome, why doing it?

Often modders don't have time or the possibilities to test their mod as extensively as the userbase can. Unexpected behaviors can occur because of special mod compositions or configurations. By profiling your data and sharing it with the modder, he can pinpoint possible problems within his code and thus help him make a better and more lag-free mod.

Nice! I want to help, what do I need?

To profile you need a profiler (dun dun). There are some mods out there which help you like TickProfiler but they only indicate problems, but do not deliver extensive information for the modder himself. The tool generally used to profile Java Applications is JVisualVM.

When am I supposed to profile?

When you notice your ticks per second (TPS) drop or lag which is unrelated to your frames per second (FPS), you can do a profile to see what is the culprit. It is important to profile the moment when it is lagging.

Where do I get it?

Since Java 6 JVisualVM is part of the Java Development Kit (JDK) and requires the JDK to run. If you have already downloaded and installed the JDK you can skip this step. Open the JDK download page and scroll down to the download links.
12 Sep 2014 Oracle JDK 8 Downloadpage
You need to accept the License Agreement to be able to download any files. Choose the JDK needed for your operating system. Most popular are Windows, Linux and Mac. x64 indicates that this software is written for 64-Bit CPUs. If you have a 64-Bit processor then download for example the file labeled with Windows x64 else choose the Windows x86 for a 32-Bit System. JDK ships the JRE, so by installing the JDK you don't need to install the JRE too. Follow the provided installation instruction by the installer.

How do I run it?

Open the JDK installation folder and search for a bin folder. Within this folder you should find a jvisualvm(.exe for Windows). An example would be C:/Programs/JDK 8/bin/jvisualvm.exe. When starting JVisualVM up for the first time you get notified that it needs to be calibrated and you should close all performance draining application.
12 Sep 2014 Oracle JDK 8 JVisualVM Calibration Notification

How do I profile?

When you start up Minecraft, you will notice a new application appeared in JVisualVM.
12 Sep 2014 Minecraft in JVisualVM
When you double-click it, it should open up the side view. Open the sampler tab.
12 Sep 2014 Sampler Tab
Press the CPU button whenever you think you can reproduce the lag spikes and profile it as long as you can. The longer the time you profile the better the results can be, because it will contain less fluctuation and abnormalities. You will see some fancy action going on. After some time hit the Snapshot Button. Notice the profile will not stop by snapshotting it.
12 Sep 2014 Snapshot Button
In the newly opened snapshot tab press the 2. of the 3 Disk Icon labeled with Export to...
12 Sep 2014 Export to Button
Choose an appropriate file name and save it to a location of your liking with the extension *.nps. This file can be opened again with JVisualVM so AlgorithmX2 can look at it.

Now I have this pretty file, what to do with it?

Post the file on the tracker or send it to AlgorithmX2 through his IRC channel #AppliedEnergistics on Espernet. Please be patient, but I can assure he read every profile so far and it helped improving the mod by a great deal.

Just give me the links!

Last modified on 09/12/2014 01:18 PM CDT
By thatsIch