01-17-2019 05:06 AM - edited 01-17-2019 05:12 AM
Hello everyone,
I am currently developing a program that displays computer information, such as CPU/GPU load & temperature. The idea is that the program will be running continuously, while games and other high-resource software is running. However, it seems that CPU usage is a bit high; peaking at around 20% utilisation.
Are there any ways I can cut down on CPU usage? I have tried messing around with the iteration delays, but haven't had much luck. I currently have multiple loops all doing different tasks at the same time. Would it be best to process everything sequentially (with a flat case structure, for example) or can I just let LabVIEW deal with the threading automatically? Also, are there any tools that would let me see CPU usage per VI or loop?
I have attached a screenshot of the VI, any help would be appreciated.
Thanks,
Ryan
01-17-2019 09:25 AM
Doing a few things wrong.
Firstly, you're creating and destroying .NET objects in each loop iteration. Create it once before the loop, pass the wire into the loop, make the measurements and then when exiting the loop, pass the wire out again (Make sure to wire it to shift registers) and only close it when the program is stopping.
Secondly, try not to use property nodes for reading FP values, use local variables instead. It's a lot faster.
Just the first two things which occurred to me.
01-17-2019 09:33 AM
I am having a hard time wrapping my head around why you would do something like this...
Nesting 4 infinite loops inside an infinite loop just doesn't compute.
01-17-2019 09:34 AM
They're not infinite loops, but the outermost loop is just not required at all.
01-17-2019 09:49 AM
Is it really necessary to write something new?
There are tons of ready to use programs available for that use case, like MSI Afterburner to name only one.
01-17-2019 09:53 AM
Thanks for the fast replies guys!
I will change the property nodes to local variables; I thought it was the other way around for some reason!
As for the loops; the nested loops activate sequentially, since if I tried to ping all four addresses at the same time, it would return an error. Although I suppose a case structure would be a much cleaner way of implementing it.
In regards to the .NET object, I previously tried creating the object outside of the loop, but it would return with null. However, I haven't tried hooking it up to a shift register, so thanks for the tip!
Much appreciated,
Ryan
01-17-2019 09:55 AM
@aptivo wrote:
Is it really necessary to write something new?
There are tons of ready to use programs available for that use case, like MSI Afterburner to name only one.
Maybe this person is like me; like to program things just because it's fun, or to keep the ol' LabVIEW skills sharp.
01-17-2019 10:02 AM
I got that point. If this would have been a time-critical task, I’d only like to show an easy workaround.
01-17-2019 10:35 AM - edited 01-17-2019 10:36 AM
@Ryan5 wrote:
As for the loops; the nested loops activate sequentially
Actually they don't. They all run at the same time. The difference in behaviour compared to when the outer loop simply doesn't exist is most likely negligible. There is no data dependency between them forcing them into sequential operation at all.
01-17-2019 10:44 AM - edited 01-17-2019 10:49 AM
Ah yes I've just done some testing and you're right! They only appear to be activating sequentially since it can only ping one target at a time. I'll re-arrange that part into a case structure.
Thanks for pointing that out!