05-03-2021 02:01 AM
I’m looking for string functions which takes string array as an input and throws the array of processed stings. Has anyone come across any functions to process the array of stings by direct function call ?
Soemthing like this,
We all know, we have string function in LabVIEW which takes sting input and throws the processed sting out. Let’s say we have an array of stings and each element of the array needs be processed in same manner, then the typical method is we use a for loop to achieve that. Due to processing speed limitations, I can’t use the For loop.
Thank you
Adarsh
05-03-2021 02:34 AM
Hi Adarsha,
@AdarshaPakala wrote:
Let’s say we have an array of stings and each element of the array needs be processed in same manner, then the typical method is we use a for loop to achieve that.
That's the way to go: place a FOR loop around that string function!
@AdarshaPakala wrote:
Due to processing speed limitations, I can’t use the For loop.
You really need to explain that sentence! Which kind of limitations do you hit???
05-03-2021 03:37 AM
@AdarshaPakala wrote:
I’m looking for string functions which takes string array as an input and throws the array of processed stings. Has anyone come across any functions to process the array of stings by direct function call ?
Soemthing like this,
We all know, we have string function in LabVIEW which takes sting input and throws the processed sting out. Let’s say we have an array of stings and each element of the array needs be processed in same manner, then the typical method is we use a for loop to achieve that. Due to processing speed limitations, I can’t use the For loop.
If you wrap a for loop as a sub-vi it looks like one function. 🙂 Regardless if you place the loop of it's 'built in' into a function it'll still need to iterate all those strings.
However, this function is the type that can gain lots by having a Parallelized loop.
05-03-2021 04:43 AM - edited 05-03-2021 04:45 AM
thank for your reply!
execution time is my limitation 😊
I have more than 15000 elements in the array and I get that array for every 10mS. If I put it inside the For Loop its runs 15000 iteration per process and For Loop needs time to complete the iteration which is my limitation. I'm thinking if I could do the array operation it would be faster than looping.
Thank you
Adarsh
CLA from 2014
05-03-2021 04:53 AM - edited 05-03-2021 04:55 AM
Hi Adarsh,
@AdarshaPakala wrote:
I have more than 15000 elements in the array and I get that array for every 10mS. If I put it inside the For Loop its runs 15000 iteration per process and For Loop needs time to complete the iteration which is my limitation. I'm thinking if I could do the array operation it would be faster than looping.
Even when there would be a function with an array input: it would need to process the very same 15k array elements in the very same way!
The overhead of the FOR loop is next to zero for this type of application - and you can use it to parallelize that task quite easily!
(Your example of the StringSubset function suggests a quite heavy MemoryManager usage as each string will get resized, leading to quite a lot of memory (de)allcations in your loop. This might be the slow part of the execution, but not the FOR loop construct…)
Can you provide an example VI with some example data? Maybe we can help you with improving that string manipulation!?
05-03-2021 05:18 AM
If the string functions are 'heavy' it might actually be faster to store the result in a Map, then you'd only do the work one time and then it's a look-up. This is of course assuming the strings are rather repetitive.
So, String in as key, look up the result. If there is none, perform the function and store for further usage.
05-03-2021 08:25 AM
@AdarshaPakala ha scritto:
thank for your reply!
execution time is my limitation 😊I have more than 15000 elements in the array and I get that array for every 10mS. If I put it inside the For Loop its runs 15000 iteration per process and For Loop needs time to complete the iteration which is my limitation. I'm thinking if I could do the array operation it would be faster than looping.
Thank you
Adarsh
CLA from 2014
Precisely, how many new samples you get for each 10 ms acquisition time? 15000 seems to be a little too much.
05-04-2021 08:38 AM - edited 05-04-2021 08:39 AM
Samples are between 14950 to 15000, its coming from highspeed quad USB ports.
It’s a data parsing logic. I have optimized the sting manipulation as much as possible(did not use any complex sting function, string subset, match pattern functions are used), i don’t think further optimization of parsing logic is possible.
I think if i have sting functions with array input(like MATLAB), then looping can be avoided.
Thank you
Adarsh
CLA from 2014
05-04-2021 08:42 AM
Hi Adarsha,
@AdarshaPakala wrote:
It’s a data parsing logic. I have optimized the sting manipulation as much as possible(did not use any complex sting function, string subset, match pattern functions are used), i don’t think further optimization of parsing logic is possible.
Well, a second opinion on your optimizations might be fine, don't you think?
@AdarshaPakala wrote:
I think if i have sting functions with array input(like MATLAB), then looping can be avoided.
Such a function will have that loop "built in", it still has to process all of those 15k array elements!
So the "looping" is not avoided, but only hidden…
05-04-2021 09:30 AM
@AdarshaPakala ha scritto:
Samples are between 14950 to 15000, its coming from highspeed quad USB ports.
It’s a data parsing logic. I have optimized the sting manipulation as much as possible(did not use any complex sting function, string subset, match pattern functions are used), i don’t think further optimization of parsing logic is possible.
I think if i have sting functions with array input(like MATLAB), then looping can be avoided.
It's a lot of data indeed.
However, the amount of parallel processing your system can do is limited (very roughly) by the number of processor cores.
Since the job is done by the processor(s), unless yours system features thousands of processors, a loop is unavoidable, although this may be hidden by the code syntax.