using this simple 60fps clock (16ms are 62.5 fps) complete use up all of my system resources
win10 task manager say:
cpu: 100% (all 4 cores)
gpu: 95% 3D
How can this simple gui snippet use up 4 cores 100% of 3,72gHz cpu and almost 100% of its IGP just by display current time?
Are there any better ways to display a clock?
Note: Colors have to be green and white as it's overlayed and keyed out (color key) for a video.
Before someone comes and try to smart-arse: even slow down to 2sec (2000L) sleep doesn't solve the issue - system still used up 100% - so change the "speed" of the clock doesn't seem to affect resource usage.
It works fine on my system, with the application using no more than 2% of my CPU. My guess is that since you're calling invokeAndWait() 62 times per second, you're flooding the EDT with update requests that really could be coalesced. I'm thinking a lot of the time is spent on thread context switching.
Never create your own threads. Thread is a low level primitive and high level code should use executor services instead. Try this code and tell us if it makes any difference:
~scraped down version~
Well, sadly, the resource usage hasn't improved a bit - still full system usage.
When I run it on my main rig I also only get 1-2 % usage - and my GPU doesn't even use 3D but does it all in 2D as it sees it as part of normal desktop window.
So, it seams that not the java code itself be the problem but somethings worng when its run on the 2nd machine.
According to sources the A10-7800 is a newer architechture than my FX-8350 - so it should run the same stuff with more efficiency - I really wonder why it runs way better on a system overall way older than on newer hardware wich should had no problem running it.
I also tried to reduce it to 1FPS (so, remove the millisecond at call it only once each second) - surprisingly - the system load does not decrease a tiny bit. So, even with this improved code, and also "slowed down" to each second instead of each 1/60 second - the system still use all resources to display that simple clock. Maybe it's something hardware related. I don't have more systems than these two, but it's so strange that a simple clock only updated once a second needs the whole system power.
Don't get me wrong - the 2nd system is powerful enough - it even can live stream 1080p60 with 6.000kBit/s - a very demanding task - wich only use up the system to about 75% of overall power. Can it really be something java-specific related causing that so strange issue? I'm out of ideas ...
Actually, you might want to check the graphics card settings in the OS. It's possible you don't have optimal settings for graphics and the CPU is being required to make up the difference,
When working with Swing, the task of rendering the display is the responsibility of the Swing internal graphics threads and they run on their own schedule. Whether you update the graphics text once every millisecond or once every 5 hours, the maximum load on the display logic is going to be about the same, since all Swing does is prep the graphics so that the framebuffer can pick them up on the next hardware display scan.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
Well, thanks for the additional input - I checked - but other than energy management (wich is the first I set to max when ever I set up a new system) there is none I can set. The driver only allows me to see current status and change resolution - but that's it.
The only other difference: the main rig runs Win7 - the 2nd machine Win10. So, could it be a OS difference that, for what ever reason, win10 thinks it needs 3d acceleration when my win7 system don't even bother with 3d but all in 2d (as I expect it)?
That's what really bothers me - why it's even rendered in 3D acceleration (and therefore raise the gpu to its high power state when actually no need to) instead of plain 2d drawing? This doesn't seem right.
Oh, and about the format: you used "hh" - wich is 01-12 am/pm - but without am/pm indicator - I changed it to "HH" wich is 00-23 as I'm used to (I'm german, but use the english locale to get english shorts for day of week and month instead of german wich would default to when no locale is set - but actual keep the german standard 00-23 instead of 1-12 am/pm used in many other countries).