04-04-2008 02:48 PM
04-04-2008 05:48 PM
04-05-2008 01:56 PM - edited 04-05-2008 01:59 PM
It makes no sense that code can speed up by a factor of 10 if the computer actually needs to do more work (dragging a window, etc.).
Something must be either terribly wrong with your code or there is posssible (unlikely) that you are exposing an unknown bug in LabVIEW.
What is the CPU usage if you don't drag windows around? Since you are saying the CPU usage goes up to >60%, I am assuming that the CPU usage is maybe <10% when it is supposed to do real work. I have no problems filling my CPUs to 100% for any real computations, while keeping the UI responsive at the same time. You need to find out why the processor is not kept busy if you are only watching it process images.
First of all, we need to know how you measure the speed of your code. Do you have actual code timing with and without your tweaking? Watching the CPU meter alone does not tell how much is spend on your computations.
If you cannot keep your processor busy working on your data, you need to inspect your code. Chances are that your code is not optimal and your code is spending most of the time making data copies in memory and switching threads or dealing with synchronous property nodes. How about race conditions? Do you have sufficient RAM or is swapping involved? Is there any hardware involved. Are the images to be processed available locally or do they come from a network server or imaging ssystem?
What kind of image manipulation are you doing? How big are the images? How many CPU cores do you have?
04-05-2008 02:29 PM
Actually, I saw something not dissimilar a few days ago. I wrote some quick and dirty code to do something with the picture control, but it was very slow (it would take a second or two to run a loop instead of ~10 ms).
I decided to do a quick test by placing a couple of Tick Count nodes and measuring the difference to see which part of the code was taking up the time. Since the individual parts of the code were running fast inside for loops, I decided to stop the VI to see the exact section which was taking up the time, but each time I stopped the VI the indicators were showing numbers which were too small. After a minute of playing with this, I realized that whenever I pushed the abort button the VI would start running faster. If I kept it pushed, the VI would keep running faster (although I didn't check the CPU usage).
I didn't look into it, but I suspect some sort of thread swap issue or something else along those lines.
04-07-2008 09:19 AM
04-07-2008 10:27 AM
A bit more info:
When I wrote this morning, the program ran at >50% CPU. When I run it now (again, not changing any code), it runs at >60% CPU. Also, by my qualitative speed measurement, it seems to have picked up the pace a little bit as well.
Maybe it doesn't have anything to do with the code, and has to do with something else going on on the computer?