Make sure you're fair in benchmarking the full code. Currently the entire first loop is "folded" into a constant in 8.20. If the names are allowed to change at runtime, this would need to be recalculated. How expensive is that actually? Sorry, I rarely use variants... 😉
Hopefully this example VI clears up some of the confusion.
That example wasn't intended to be benchmarked...I just wanted to demonstrate how you would populate, then later read, the variant attributes.
Message Edited by Underflow on 10-09-2006 03:00 PM
"Of course worrying about performance for things like that makes only sense for huge data structures. ".
On a PC yes...On a PAC no. On PACs you run into a performance issue pretty quick as the standard search is in the order of 20 times slower than on a PC....
With the variant attribute-trick the PAC can even outperform a PC running the standard search.
would you be able to post the code for the approaches? I want to get a better handle on them.
Actually I was building a "generic" functional variable than hold arbitrary variables. I started using a simple array of strings but then I learned about this variant trick described here. However this performes much slower in my code than the 1D array of strings (I use the "substitute variable" convention to define variables). In my small test vi it turnes out that the array can be written 5 times faster than the variant using the set variant attribute vi.
For the array I am first searching the array for the name of the variable to then replace the value string. So I am wondering if this variant attributes only perform better at low number of attributes?
What version of LabVIEW are you using? There appears to have been a significant boost in Variant Attribute performance between LV 8.6 and 2009.
Something doesn't sound right, I would expect that the variants would perform better (for searches) as the array size grows.
If your previous array implementation has a small number of elements and the elements are sorted, that might explain the good performance.
Most discussions on the forums that involve the Variant Attribute technique suggest that the variants will always be faster for moderate to large arrays.