The complexity analysis view allows you to investigate the algorithmic complexity of selected methods
depending on its method parameters.
If you are unfamiliar with big O notation, see this introduction to algorithmic complexity and this list of complexities for common algorithms. |
Complexity recording is independent of CPU recording. First, you have to select one or more methods that should be monitored.
If no methods have been configured, the configure button
is shown directly in the view, and it can always be found in the tool bar or in the View menu.
The following ways for selecting methods are available:
In the script editor, you can then enter a script whose return value of type long is used as the complexity for the current method call. For example, if one of the method parameters of type java.util.Collection is named inputs, the script could be inputs.size(). You can temporarily disable a method configuration by deselecting the check box in front of the script configuration. In that case, no complexity recording will be performed for the corresponding method. |
You can start and stop complexity recording directly in the complexity analysis view or by adjusting a
recording profile. In addition, you can start or stop
recording with the "Start recording" and "Stop recording" trigger actions,
the command line controller as well as the
profiling API.
After recording has been stopped, a graph with the results is displayed plotting the complexities on the x-axis against the execution times on the y-axis. To reduce memory requirements, JProfiler can combine different complexities and execution times into common buckets. The drop-down at the top allows you to switch between the different configured methods. The graph is a bubble chart, where the size of each data point is proportional to the amount of measurements in it. If all measurements are distinct, you will see a regular scatter chart. In the other extreme, if all method invocations have the same complexity and execution time, you will see a single large circle. |
If there are at least 3 data points, a curve fit with common complexities is shown. JProfiler
tries curve fits from several common complexities and initially shows you the best fit. The drop-down for the curve fits
allows you to show other curve fit models as well. The R2 value embedded in the description of the
curve fit shows you how good the fit is. The models in the drop-down are sorted in descending order
with respect to R2, so the best model is always the first item.
Note that R2 can be negative, because it is just a notation and not really the square of anything. Negative values indicate a fit that is worse than a fit with a constant line. The constant line fit always has an R2 value of 0 and a perfect fit has a value of 1. You can export the parameters of the currently displayed fit by choosing the "Properties" option in the export dialog. For automated analysis in a quality assurance environment, the command line export supports the properties format as well. |