LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

False case takes significant time to execute despite being empty

I have a loop that's gathering data quickly and another loop that wants a snapshot of loop1's data, will do some processing on that data, and show the latest status. My goal is to minimize the disruption to loop 1 and only send occasional snapshots of the data to loop2.


What's interesting is that even if I leave the boolean false so that the empty case runs (I don't send any copies to loop2), the empty structure still requires significant processing time. Is this an optimization that isn't working for me? Is there a way to control the behavior more to what I'm looking for?

 

copy threat.png

0 Kudos
Message 1 of 9
(348 Views)

Modifying the value of the map is what is taking up the most time. If you wrap that in a diagram disable structure it executes almost instantly.

0 Kudos
Message 2 of 9
(336 Views)

Well, it only measures the elapsed time between the outer frames, so the map generation should not matter.

 

Of course it is highly unlikely that two random numbers ever repeat, so that map grows very quickly, probably stealing a lot of CPU from the rest of the diagram to manage its data in parallel of running the sequence. Once you make duplicates more common, things speed up.

 

(e,g the following will limit the map size to 100 entries and everything is fast.)

 

altenbach_0-1738275241857.png

 

I also recommend the high resolution relative seconds for the timing.

0 Kudos
Message 3 of 9
(330 Views)

@Gregory wrote:

Modifying the value of the map is what is taking up the most time. If you wrap that in a diagram disable structure it executes almost instantly.



Surprisingly, the empty case structure takes 45 seconds of processing on my PC and the insert/increment code takes 0.05 seconds.

 

bench increment.png

0 Kudos
Message 4 of 9
(312 Views)

@altenbach wrote:

Well, it only measures the elapsed time between the outer frames, so the map generation should not matter.

 

Of course it is highly unlikely that two random numbers ever repeat, so that map grows very quickly, probably stealing a lot of CPU from the rest of the diagram to manage its data in parallel of running the sequence. Once you make duplicates more common, things speed up.

 

(e,g the following will limit the map size to 100 entries and everything is fast.)

 

altenbach_0-1738275241857.png

 

I also recommend the high resolution relative seconds for the timing.



Yes, that was somewhat intentional. In my real use case, I have a lot of bins so I know it's going to take some time to make the "copy" which is why I wrapped it in a case structure. I had the intent of only occasionally enabling the "copy". My loop1 can tolerate an occasional long iteration but it needs to usually run fast.

0 Kudos
Message 5 of 9
(308 Views)

@nanocyte wrote:

@Gregory wrote:

Modifying the value of the map is what is taking up the most time. If you wrap that in a diagram disable structure it executes almost instantly.



Surprisingly, the empty case structure takes 45 seconds of processing on my PC and the insert/increment code takes 0.05 seconds.

 

 


 I think you've got those backwards

0 Kudos
Message 6 of 9
(297 Views)

@Gregory wrote:

 I think you've got those backwards


Nevermind, I think I saw something similar before my VM crashed, haha

0 Kudos
Message 7 of 9
(290 Views)

I saw very little difference between the true and false case.

0 Kudos
Message 8 of 9
(273 Views)

That's what I'm confused about. The false case is empty. It should be very fast.

0 Kudos
Message 9 of 9
(269 Views)