0

I've been profiling my swing application which is visual and does a lot of repainting: by calling repaint and doing paint in paintComponent().

I am using VisualVM and used the Sampler to see which methods use a lot of cpu.

A lot of my paint methods are at the top of the list, no surprise there.

But a strange effect can be seen, every time i start my application and start a cpu sample session different paint methods are at the top of the hot spots.

I find this strange because i use the exact same data set in my application.

Is it possible that something (maybe swing paint model) is messing up the visualvm results?

T. Akhayo
  • 411
  • 6
  • 13

1 Answers1

1

You have to keep in mind that Swing is an event driven system. It is unlikely that the events will ever occur exactly in the same order.

Also, the repaint manager is at the mercy of the OS. The OS may be making requests to the repaint manager to update sections of it's UI based on it's own requirements, again, these are unlikely to occur exactly the same way each time.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • Thanks for your reply. My window repaints on every mouse move, so while moving the mouse wildly every time visualvm will get a overall average after some time. This rules out other effects. The problem is more the amount of difference in the cpu usage, one time paint method x has 70%, paint method y 10%, next time method x has 20% and method y has 60%. These difference are seen on most paint methods. It doesn't make much sense to me ;-) – T. Akhayo Oct 30 '12 at 22:31
  • @T. Akhayo performance depends of refresh ratio (how much / per second), and most imposrtant is screen size (extremly diff is betweens 800x600 and for full hd ) – mKorbel Oct 31 '12 at 05:45