From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

substitute of build array function

Can you suggest any function which works as afunction of  Build Array instead of using diectly Build Array Function.

0 Kudos
Message 1 of 8
(3,859 Views)

Use autoindexing…

 

What's the purpose of replacing such a basic function?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(3,857 Views)

Usually by using Build Array Function,it takes much time for executing when element are more than 100,since it allocates memory dyanamically(i.e one by onebehind each other).SO,We have to avoid using Build Array when we are handling more elements in a Array.

0 Kudos
Message 3 of 8
(3,843 Views)

If you know the expected (or maximum) size of the array then you can use the initialise array function to allocate the memory for the array in advance and then use the replace array subset function to fill the array. You will need to keep track of the index (so you know the size of the array) and the array in a shift register. 


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 8
(3,838 Views)

Good : Build Array, Insert into Array

Better : Auto-index

Best : Initialize Array + N x Replace Array Subset. (+ Resize Array, if needed)

 

Hope this helps 🙂

 

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

0 Kudos
Message 5 of 8
(3,837 Views)

@ZentronLV wrote:

Usually by using Build Array Function,it takes much time for executing when element are more than 100,since it allocates memory dyanamically(i.e one by onebehind each other).SO,We have to avoid using Build Array when we are handling more elements in a Array.


If you are dynamically building your array, it doesn't really matter what you use.  You will have the same problem.

 

But if you know the max size, initialize array and use Replace Array Subset is definately the way to go.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 8
(3,816 Views)

Yup as others have said.  Preallocate, then use replace.  I believe the conditional concatenating terminal out of a for and while loop, first had a normal build array being used behind the scene.  Users in 2012 noticed this performance wasn't that great, and could code better conditional indexing functions, by pre-allocating.  Since then NI has improved the performance and I suspect it uses the pre-allocate method.

0 Kudos
Message 7 of 8
(3,726 Views)

@ZentronLV wrote:

Usually by using Build Array Function,it takes much time for executing when element are more than 100,since it allocates memory dyanamically(i.e one by onebehind each other).SO,We have to avoid using Build Array when we are handling more elements in a Array.


You need to be much more specific what you are trying to do. Maybe show us some code.

 

  • Is the building a one-time thing or over and over inside a loop?
  • Do you know the final array size?
  • How do you measure the execution time?
  • The definition of dynamic allocation is not "onebehind each other". Arrays are contiguous in memory, so if space runs out, the entire array needs to be moved to a sufficiently large stretch of memory elsewhere.
  • You don't have to avoid "build array", you have to avoid constant resizing of your arrays, no matter what tools you use. This means you potentially need to rewrite certain code sections.
0 Kudos
Message 8 of 8
(3,719 Views)