In light of your first set of comments, I dived in and just felt around the UI as it bore little resemblance to the document.

 

As you point out, I did get the offer to do an initial calibration when I first asked to do a profile.

 

 

 

Fortunately, I did not see the issues you reported below and as a novice to this tool, can’t be of much help as to interpreting your exceptions.

 

The profiler did present views for each of its options in the drop-down (part of Profile button) and found the ‘Method’ option to be the most useful. I had deliberately, during coding, left a sequential scan within the code that I knew needed optimising to see if the Profiler would spot it.

 

The good news is that it did and reported that most of the time was spent inside this method. I was optimistically hoping to see a count for each line of code visited as that would be ideal for my analysis, as given a specific test set of data, I know how often I am expecting each piece of code to be executed and so if the number of iterations were high then I could investigate further. The ‘hot spots’ icon allowing a quick drill down into the methods and sorting them by the time spent within each method.

 

I did find a column for the number of ‘hits’, as opposed to Total Time, by selecting the drop down arrow on the far right hand side.  However, the number presented was meaningless to me as was way too low. To prove this, I wrote my own debug method to log iterations for specific methods to evaluate a true figure. For example, a method ‘FindDuplicateRow’ reported 403 hits, yet by counting the number of executions of this method I had 48,219!

 

So, while my initial requirement was not met (number of times each line of code executed), the time spent in each of the main methods at least gave an indicator of where inefficiencies may be.

 

When I first looked around, I can see that there are several plugins to purchase but as a amateur developer, I can’t justify the expense and so this built in one is probably a reasonable substitute.

 

The only issue that I have currently discovered is that it appears that you can profile a specific class or method, which the online documentation also discusses. The UI for this is very clean (right click the suspect routine and select ‘Profile method’ or ‘Profile class’) but if I then run the profiler again, it runs but never displays anything, regardless of what method / class I pick and so I can only profile the whole project. The Output window appears to think that everything is not as it should be as I get the following output with several ‘Profiler engine warning: ...’ messages (see below)

 

 

-------------< com.propertymanagement:propertyManagement >--------------

Building propertyManagement 1.0

--------------------------------[ jar ]---------------------------------

 

--- exec-maven-plugin:3.0.0:exec (default-cli) @ propertyManagement ---

Profiler Agent: Waiting for connection on port 5140, timeout 10 seconds (Protocol version: 18)

Profiler Agent: Established connection with the tool

*** Profiler engine warning: Cannot use ClassLoader.findLoadedClass() and/or ClassLoader.findBootstrapClass() in ClassLoaderManager

Profiler Agent: Local accelerated session

Profiler Agent: Initializing...

Profiler Agent: Options: >C:\Development\Netbeans\Netbeans-12.6\profiler\lib,5140,10<

Profiler Agent: Initialized successfully

Profiler Agent: 250 classes cached.

Profiler Agent: 250 classes cached.

Profiler Agent: 250 classes cached.

Profiler Agent: 250 classes cached.

Profiler Agent: 250 classes cached.

Loaded the database configuration for C:\Development\Work\PropertyManagement\Configuration\Configuration.json

Read the database dictionary for propertyManagement    0:00:00.044.502500  [Elapsed   0:00:00.044.502500]

Published database dictionary for propertyManagement    0:00:00.054.744300  [Elapsed   0:00:00.099.246800]

Import data from c:\PropertyManagement\    0:00:00.002.900500  [Elapsed   0:00:00.102.147300]

*** Profiler engine warning: class java.security.AllPermissionCollection loaded by *** Profiler Agent Communication Thread

*** Profiler engine warning: class jdk.internal.reflect.GeneratedMethodAccessor1 loaded by *** Profiler Agent Communication Thread

*** Profiler engine warning: class jdk.internal.reflect.GeneratedMethodAccessor2 loaded by *** Profiler Agent Communication Thread

Import data complete    0:00:36.330.365900  [Elapsed   0:00:37.207.295700]

Execution time:   0:00:37.207.452500

Debug messages for [SQL statement] written to c:\Log\PropertyManagement.log

Profiler Agent: Connection with agent closed

Profiler Agent: Connection with agent closed

Profiler Agent: 250 classes cached.

------------------------------------------------------------------------

BUILD SUCCESS

------------------------------------------------------------------------

Total time:  47.465 s

Finished at: 2022-01-29T20:56:58Z

------------------------------------------------------------------------

 

Now time to go and optimise my sequential scan!

 

John

 

 

From: Peter Ream
Sent: 29 January 2022 19:18
To: users@netbeans.apache.org
Subject: RE: Re: Introduction to Profiling Java Applications in NetBeans IDE

 

I found this intriguing. I know nothing about “profiling”, but thought this was a good opportunity to learn something new. I started reading the tutorial, and with Michael’s help was able to get started, but cannot get through calibration. See attached messages.Probably user error.

On 2022/01/29 15:36:33 Michael Bien wrote:
> Hi John,
>
> I could find the Anagram Sample in the Samples -> Java with Ant category.
>
> The profiler will automatically calibrate on first run. The UI/UX
> changed a bit. You press profile to open the profiler tab and then press
> profile again in the tab to actually profile the project. The drop down
> lets you select the various modes.
>
> hope this helps,
>
> -mbien
>
> On 29.01.22 15:21, John wrote:
> >
> > Hi,
> >
> > I have completed my Java 17 project in NetBeans and now interested in
> > the profiling built into NetBeans for the first time. Having come from
> > an old development environment where these tools didn’t exist, I am
> > looking forward to analysing the results.
> >
> > In order to learn about this new technique (to me), I located the
> > following Apache NetBeans article.
> >
> > https://netbeans.apache.org/kb/docs/java/profiler-intro.html
> >
> > I have already upgraded my NetBeans to the latest 12.6 version as
> > titled in the header of the article and am using the latest version of
> > the JDK (17).
> >
> > However, I am confused as I can’t locate the ‘Anagram Game’ in the
> > list of Samples that ship with NetBeans (screenshot below).
> >
> > I checked the Github link that is included in the article and that
> > shows that the latest commit to the article was on Feb 2, 2020 and so
> > looks to be up to date and relevant.
> >
> > Anyway, I continued with my own project rather than the one detailed
> > in the documentation and then came to another halt at
> >
> >
> >       Using the Profiler for the First Time
> >
> >  1. Choose *Advanced Commands* > *Manage Calibration Data* from the
> >     Profile menu.
> >
> > As I don’t appear to have an option for that on my Profile menu. That
> > looks like below on my version of NetBeans.
> >
> > So I think that I am missing something obvious here as the tutorial
> > seems to be referring to items that I can’t locate.
> >
> > Do I need to install a plugin?
> >
> > I was also a little concerned that the documentation focused on JDK 7
> > (1.7) which stopped being supported in April 2015.
> >
> > I am happy to update the screenshots and menu-paths etc to relate to
> > the latest version of NetBeans / Java, but before tampering with the
> > article, I should really understand what I am doing and the target
> > audience the article is intended for.
> >
> > As a rule, I really appreciate these work-through guides as it
> > normally gives me an excellent foundation from which to explore from
> > and convinces me that the functionality works as intended before I try
> > it on my own project. That way, I know any issues are down to me and
> > not the way that the software has been configured, as in the classic
> > ‘Hello World’ principle.
> >
> > If anyone can help me fill in the gaps detailed above, that would be
> > appreciated and allow me to continue exploring the article.
> >
> > Thanks
> >
> > John
> >
> 

 

Reply via email to