10-22-2013 02:03 PM - edited 10-22-2013 02:04 PM
@Hooovahh wrote:
Hope you don't mind but I found orders of magnitude improvement by removing the for loop, and replacing the while loop with a for loop. In my test running the code 10000000 times took about 8459ms to execute, but after these two changes took 2ms. I tried a few other ideas but couldn't come close to this. Oh automatic error handling and debugging was turned off for the test.
Your benchmark is flawed because the inner FOR loop is folded.
What is the size of the boolean array input?
10-22-2013 02:16 PM
@altenbach wrote:
Your benchmark is flawed because the inner FOR loop is folded
I see no difference between the while loop and the for loop implementation with an initialized array of size 10,000,000. However Will's code doesn't have the conversion to 1's and -1's so his code runs faster.
10-22-2013 02:16 PM - edited 10-22-2013 02:20 PM
altenbach wrote:
Your benchmark is flawed because the inner FOR loop is folded.What is the size of the boolean array input?
My boolean array size was around 15 I forgot to set the default values. You say my inner FOR loop is folded? I only have one for loop is that the one you are refering too? I'll try again with randomized data (the same randomized data for the other method).
EDIT: With randomized data I still get large improvements over the original I forgot to test Wills method against it.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-22-2013 02:18 PM
For a boolean array input of 10M and folding eliminated, both aputman's and hoovah's code are about 800ms, while my variant (not shown) takes 150ms. There is room for improvment, guys! 😄
10-22-2013 02:20 PM
@altenbach wrote:
For a boolean array input of 10M and folding eliminated, both aputman's and hoovah's code are about 800ms, while my variant (not shown) takes 150ms. There is room for improvment, guys! 😄
That's why you are the champion.
10-22-2013 02:27 PM
10-22-2013 02:37 PM - edited 10-22-2013 02:38 PM
@altenbach wrote:
For a boolean array input of 10M and folding eliminated, both aputman's and hoovah's code are about 800ms, while my variant (not shown) takes 150ms. There is room for improvment, guys! 😄
Alright Mr. Champion see if you can beat this (you probably can). 10M booleans aptuman's version 470, Wills 797, mine 72, your milage may vary. (Case 3 in this structure)
EDIT: I realized I cheated a little, I have 80% TRUE and 20% FALSE in my boolean array, setting it to 50% does make it take longer.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-22-2013 03:12 PM - edited 10-22-2013 03:13 PM
My solution was a much simpler modification and was based on the fact that the conditional tunnel is not well optimized at guessing the final allocation size. 😉
10-22-2013 03:17 PM
@altenbach wrote:
My solution was a much simpler modification and was based on the fact that the conditional tunnel is not well optimized at guessing the final allocation size. 😉
Notice that my solution also didn't use the conditional tunnel (I'm aware of the not ideal performance too), and the loop does not iterate for every element in the array, but instead loops for every transition from TRUE to FALSE or FALSE to TRUE.
Are you ready to post your solution yet? Have I come close enough to yours in terms of speed?
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-22-2013 03:35 PM - edited 10-22-2013 03:42 PM
I haven't really tested it, but here's what I came up with. 😄 I think it is slightly faster than yours (at least on 2013). 😉
(The select node and add could be replaced by a case structure containing +1 or -1, resp. Does not seem to really make a difference)
According to some casual testing, I think it performs correctly.