Thomas S.
Thomas S.

Reputation: 6365

Profile Java GUI application for responsiveness

When developing a Java GUI application (SWT or Swing based, should not matter), how to best profile the responsiveness, e.g. what consumes the time if the application feel sluggish on certain operations like clicking a button until something happens. The problem is in my understanding that the delays are quite low (usually < 0.5s) and hence hard to measure, because the most profilers I know you need to start and stop later.

Upvotes: 2

Views: 631

Answers (2)

Vladimir Kondratyev
Vladimir Kondratyev

Reputation: 725

YourKit Java Profiler has built-in probe which automatically records all AWT/Swing events longer than 0.3 second, which can cause UI irresponsiveness: https://www.yourkit.com/docs/java/help/awtevents.jsp

Disclaimer: I work for YourKit

Upvotes: 1

Ingo Kegel
Ingo Kegel

Reputation: 48105

The problem with profiling UI applications is that calls on the event dispatch thread (EDT) often originate from other threads or trigger background operations that eventually call something on the EDT. This can make it difficult to see the effects of a user action separately.

JProfiler has a feature called "Async tracking" that can track calls into the event dispatch threads of both AWT and SWT:

  1. You have to profile with instrumentation and enable tracking:

enter image description here

  1. Then you record CPU data and perform the actions that trigger actions on the EDT:

enter image description here

  1. Finally, you click on "Inline async executions" to see the call tree across thread boundaries:

enter image description here

Disclaimer: My company develops JProfiler.

Upvotes: 3

Related Questions