Yet another (LabVIEW) blog

LabVIEW fastest search string function


LabVIEW offers several functions for searching of strings – those are “Search and Replace String”, “Search/Split String”, “Match Pattern”, etc. Also, there are couple of function from other toolkits, like “GPower String Toolkit”, “OpenG String Toolkit”, etc.  They are not just for searching string – they have some additional functionallity like string splitting, replacing of substrings, etc. So, the question is, which of the function is more time-efficient to use?

For this, I’ve made some simple time benchmark of the functions, listed in the table below. Intentionally, I didn’t try “Match Regular Expression” function, because handling of regular expressions is a bit different story.

So, was created one VI which calls directly investigated function, and VI for exectution time measurement. Each funciton was called in the loop 1million times, and afterwards time of first loop iteration execution was removed (b/c of jitters while first run), and were found maximum, minimum, and mean time of execution.

Also, were tried two cases – when string was present it text, and when not.

Of course, I’m not saying, that this is the most precise time benchmark ever, but let’s check the results:

And, they are quite expactable. The fastest are functions, which have less functionallity inside.

So, if you want simply to check, whether some sting contains substring, Search/Split String or Match Pattern seems to be the best choice. The first one takes the least time while searching of string, which is present in string; but it’s 2 times slower when string is not present. But overall, average (mean) time for them is the same.

Leave a comment

Your email address will not be published. Required fields are marked *