Step 6 - Sampling
Now we gather profile data using the sampling mechanism. First, activate the sampler either from the Overview panel or by selecting the menu "Settings / Sampling and instrumentation rules":
The "Sampling and instrumentation rules" dialog appears:
Select the "enabled" checkbox and save the settings.
Next, send the sampling and instrumentation rules to the remote VM. Click the toolbar item highlighted below or select the menu "remote VM / apply rules":
Next, resume Example01 by clicking " Resume Process". Wait until Example01 is suspended again. Simply "Synchronize status" until the menu item "Resume process" becomes activated or watch the console output of Example01.
Create a snapshot
To create a snapshot select menu item " Create snapshot". The snapshot will be automatically displayed. Select tab "Sampler" and you should see something like this:
The code of method AbstractStringBuilder.append() (called methods excluded!) consumes 44% of the total CPU-time of thread "main". CPU-time consumption for append() and all called methods (i.e. cumulated CPU time) is 72% of total thread CPU time. The respective numbers for elapsed time are 44% and 67%.
The hotspot view lists all methods sorted by CPU-time consumption. Right-click the topmost entry of the tree (named "snapshot ....) and select " Hotspots". Subsequently, a new tab named "Hotspots" appears:
AbstractStringBuilder.append() consumes the most CPU time, followed by expandCapacity().