Today I had the need - as we all so often do - to create a lookup system to link variable names to a numeric index.
I had learned many years ago that searching in a 1D String array is very inefficient, so I had been using variant attributes and was very happy with them.
Before going down that road again, I wondered if I could give the "new-ish" Map feature a try (under the Collection palette). I had already been using it but only for small collections where performance was not a concern.
Now that I was considering using it as a standard system for variables management, where one could have hundreds or thousands of variables in the map, I needed to verify that the Insert and more importantely Lookup methods have adequate performances.
Maps look friendlier that variant, with native functions to check the collection size, to get the min and max values, and so on. I would feel better using them because it would be easier for a future developer to understand my code.
If it could match the performance of the variant in terms of speed it would be amazing. Verdict: It does!
Download Lookup Test.vi (LabVIEW 2023Q3)
Part 2:
I performed the same tests with I32 and DBL key types instead of String.
Those results are for 10,000 elements:
And those are for 100,000 elements. The array lookup performances are so bad that we can't see the variant and map times anymore.
In this final test, I tested only Maps, with a whole range of number of elements and the 3 data types.
Even with a hundred thousands string keys, the performances are amazing!