07-20-2009 02:26 PM
Could anyone give a little advise on how to optimize the attached vi. This is a sub VI wherein I send in a image ROI Global Rectangle and a full data array. I want to grab only a section of that array (specified by the Global Rectangle) and send it back.
This Sub VI works but it is prohibitively slow (as much as a second). I tried a few other methods in the hopes that the nested for loop was inherently slow. All methods I tried are also slow. There must be an efficient (fast) way to do this since there is not much to accomplish.
Any suggestions
07-20-2009 02:58 PM - edited 07-20-2009 02:59 PM
1. Bring your controls outside the loops. Leaving them inside forces the execution to check the UI for changes on every iteration.
2. Avoid using the Value attribute to write a new value to a control within the same VI. It is OK to use that for updating values on other VIs only if it is done occasionally, but certainly not in a For loop.
2. Try to maintain consistent data types, those little red dots represent conversion which means data copies being made behind the scenes.
I did a quick refactor of your VI. See if it meets your needs.
Are you using a FLIR A-series? We are using those on a project right now.
Dan Press
Certified LabVIEW Architect
07-20-2009 03:42 PM - edited 07-20-2009 03:44 PM
I addition to the above:
You could just reshape and take a subset, e.g. as follows:
07-20-2009 04:20 PM - edited 07-20-2009 04:21 PM
If you want to use two loops (maybe it's more efficient in memory?), simply correctly initialize the shift registers:
zero for the ave
Inf for the Min
-Inf for the Max
Here's a quick draft.
02-02-2010 12:26 PM
Good day Photon Dan,
Could you please further explain the following " 2. Avoid using the Value attribute to write a new value to a control within the same VI. It is OK to use that for updating values on other VIs only if it is done occasionally, but certainly not in a For loop."
or kindly direct me to an article or notes about this .
Regards
Abasani
02-02-2010 01:01 PM