This is a short overview how to do a performance analyze in GlassFish using VisualVM. When GlassFish is running and you start VisualVM it will typically connect to GlassFish. You see a local node of your GlassFish instance.
If GlassFish Server is not found than you need to verfy your profiler settings n GlassFish Web Console.
Now you can test the performance of your application deployed on GlassFish. Therefor it is useful if you can start an automated test routine like a jUnit test which creates some traffic. To start a performance test switch into the tab ‘Sampler’ and press the ‘CPU’ Button.
Now start your test routine and press stop when finished. You will see a list of all methods called during the stress test ordered by the total time.
The list of methods includes a lot of classes which maybe not be of interest for your own code. You can configure a custom package filter to select only classes of your interest. Click the Checkbox ‘settings’:
And add a filter for the option ‘Profile only packages’ with a pattern selecting only specific classes. Multiple patterns can be separated by commas.
Self Time or Total Time?
The CPU samples list includes different time columns called ‘self time’ and ‘total time’.
The ‘Total Time’ measures the time a method call takes from entering to leaving the method. This includes the time for calls of other methods. For example if you have a simple bean method which only calls a heavy backend method which takes a long time also the ‘Total Time’ of you bean method will be very high.
If you compare this to the ‘Self time’ you can see the time you method takes without measuring the external method call of the heavy backend method. So to figure out which method is the most time consuming you should look at the ‘Self time’ column.
The column ‘samples’ will show you how often the method was called.
For the WildFly application server you can use the same procedure. If you have started a local instance of WildFly you will see a JBoss Node which can be uses the same way as explained before.