In a recent discussion (Custom Array Manipulation Using Conditional Loop Tunnels ) I stated, that "build array" has a big performance penalty against auto indexing on the loop border.
But the only evidence I could deliver was:"Everyone knows this". That's always a bad argument, so I sat down to rectify that and build a very simple Benchmark.
To get meaningful results I had to use 10000000 in the array because otherwise it would be too fast on my system to give meaningful results.
The results varied wildly and sometimes I've had a run that took 5x the normal time (I guess it's some windows memory allocation stuff).
I've created 4 Variants:
- For loop with "auto index" (27ms - 43ms)
- For loop with "auto index" and parallelism activated (13ms - 20ms)
- For loop with "build array" (1130ms - 1150ms)
- For loop with "build array" (1130ms - 1150ms)
- While loop with "auto index" (49ms - 70ms)
- While loop with "build array" (1183ms - 1203ms)
Tests were performed with the attached VI on an Intel Core I7 2600 (3.4GHz) with LabVIEW 2011 (32bit) under Windows 7 64bit.
Conclusion:
The auto-index function is way faster than build array with a shift register. The difference in speed between a while loop and a for loop is there but not as big as I had expected. I could speed up the for loop significantly by enabling "loop parallelism".
Try the example code in different enviroments and LabVIEW versions and report back on the results. I'd be very interested if there are defferences between versions.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Exists a big diference between the two methods.
My results are :
For loop with "auto index" paralel
- 53 ms
For loop with "build array"
- 1598 ms
while loop with "auto index"
- 80 ms
while loop with "build array"
-1362 ms
Great post and useful Benchmark.
Thank you for this post. It's interesting to see different results.
What version of LabView are you using and on what hardware?
best
Marco
Marco
I'm using Labview 2013 Full .
My hardware is :
- CPU I3 3Ghz , 4 Gb RAM on Windows XP ( because i need some compatibility with DELPHI 7 ).
Fabricius
Your examples don't have conditional indexing which was most of the point of the original thread.
Conditional Indexing was not the scope of this test (and would not have been possible, as the used LV 2011 did not support conditional indexing).
But it would for sure be an interesting case to test as well!