2

I am working on a Java Swing Based application using Hibernate. And i have used NetBeans IDE to build my application.

I am having around 13 sub-modules. I have used JInternalFrames to build those sub-modules. And 4 reports which use JasperViewer.

While loading my application it takes around 2 - 3 minutes. And when switching from one module to another modules it takes much time to load each modules.

Now i have to check following things

  1. How to check Memory and CPU of my whole Swing application and which class takes much CPU and Memory usage?

  2. How to test my application using simple approaches?

  3. How to increase the performance of my swing application?

Vinesh
  • 933
  • 2
  • 7
  • 22

3 Answers3

3

As you are using NetBeans - use the internal profiler. That's the tool to get detailed information about where you lose the time.

For more information check the NetBeans site, e.g.

3

Startup times like these are not simply caused by having-a-big-gui-application. I think the problem is your database access. Questions come up:

  • Do you use the lazy loading feature of hibernate? This is a nice feature but can cause some issues, if not used responsible. Read this.
  • Do you cache data from the database in your application or are they fetched from the db on every action? A good way to reduce loading times is to store data in a HashMap. Hibernate has also it's own caches.
  • Do you fetch a large part of your whole database? This is not wanted, a better db schema design can prevent this, also lazy loading.
  • Is your application multithreaded? Loading the data off the event dispatch thread can by a big benefit.

To your questions:

  1. The simpliest tool comes with every JDK: jVisualVM You can store .hprof files and also analyze them in an other tool. Memory Analyzer Tools or the Netbeans profiler are also a good choice. You can also read this for further information.
  2. This depends on what you want to test. Just classes (JUnit), the GUI (UISpec4J), or do you mean profiling instead of testing?
  3. You can increase the performance by caching data, using lazy loading, or making your application multithreaded as mentioned above. You can also read here how to achieve this.
Stephan
  • 4,395
  • 3
  • 26
  • 49
0

Regarding your questions:

for 3. First measure, then cut. In most cases some simple changes can gain you 80% performance improvement.

for 1. VisualVM is a great and free tool, which will help you measure both CPU and memory consumption. Than change exactly (and only) that code accordingly.

for 2. I would suggest to take a look at ReTest. It is a relatively new tool that implements an innovative approach to functional regression testing combined with ai-based monkey testing.

Disclaimer: I am one of the founders of the company behind ReTest.

roesslerj
  • 2,611
  • 5
  • 30
  • 44
  • Excessive promotion of a specific product/resource may be perceived by the community as **spam**. Take a look at the [help], specially [What kind of behavior is expected of users?](http://stackoverflow.com/help/behavior)'s last section: _Avoid overt self-promotion_. You might also be interested in [How do I advertise on Stack Overflow?](http://stackoverflow.com/help/advertising). – Petter Friberg Mar 04 '17 at 23:05
  • I'm considering that all your last 10 answer (within 1 h) have been promoting your product. – Petter Friberg Mar 04 '17 at 23:06
  • Not quite, but close enough. Thank you very much for the links! – roesslerj Mar 04 '17 at 23:16