Step 7 - Byte Code Instrumentation
This section demonstrates how to gather detailed profile information using BCI.
Define classes to instrument
Start ProfilerJ-Viewer and select "Settings / Sampling and Instrumentation rules". Switch to tab "Profile" and include com.terrasoft.profilerj.*. Note that this is a regular expression!
Be sure that checkbox "Enabled" is selected.
Start Example01.bat now and press in order establish a connection between the viewer and the agent. Select "Remote VM / Apply instrumentation rules" and resume Example01 by clicking by clicking " Resume Process"
Create a snapshot
To create a snapshot select menu item " Create snapshot". The snapshot will be automatically displayed. Select tab "Profiler" and you should see something like this:
The method runLoop(int) (called methods excluded!) consumes 15 seconds. The overhead (see table below tree view) is 0 ms. This means that the CPU-time consumed by the ProfilerJ-agent itself is negligible. On the other hand, the cumulated values show a different picture. The overhead here is 7.9 seconds or 66% of the measured 23.8 seconds. In reality (i.e. without byte code instrumentation), the method with all its called methods would have consumed (23.8 - 7.9) seconds.
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: