Poor performance of java plugin when using GUI

Hello,

I am in the process of developing a java plugin that grabs the image files of a directory, performs colour deconvolution on each image and measures area and mean intensity using thresholding.

Intially, I did a script where a GUI was not required to write the different methods and make them work. I concluded that performance was good,I implemented this into a Swing GUI with a few buttons for user inputs. However, adding the GUI significantly slowed down the speed of the plugin from ~0.5s per image to ~5s. I then tried to build a AWT-based GUI with the same result.

Does anyone have an idea of why this is and how I can fix the problem?

Hi @Elpollodiablo,

I don’t have any idea what is causing the problem, but maybe JVisualVM (https://visualvm.java.net/) can help you finding out where the performance is lost. Simply sample or profile your program and see which method is consuming most of the time … this usually helps me a lot.

Christian

PS: Would be great if you could share the results of your investigation here… :wink:

1 Like

:+1: that profiling is the best way to detect performance problems.

For reference - profiling in jvisualvm instructions and a hands-on exercise via sample repository.

1 Like

I played around with it, but I couldn’t find a fix. In the end, I went with the GenericDialog object contained in the IJ API and modified this to my needs. Not the perfect solution, but at least it didn’t impair performance. Thanks for the replies!