LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Diagram disable adds overhead in certain cases

I was doing some timing tests of two ways to do the same thing – a typecast and flatten to string.  Well, in the process I saw a discrepancy when a diagram disable structure was wrapped around a typecast.  Without the diagram disable, 1000000 iterations took 274 msec.  With a diagram disable around the same thing, it took 1485 msec.

This scared me a bit, because technically the diagram disable case should be no different (ok, maybe a small overhead).  It further scared me, because the same overhead is invisible with flatten to string.  Inconsistent behavior…

The vi that clearly shows the “bug” in 8.0.1 is attached.

This is not a show stopper, but says “use the diagram disable structure with caution”.

Thoughts?

Message 1 of 6
(3,645 Views)

Good afternoon,

 

Thank you for posting to the NI Discussion Forums!  First (and completely unrelated), it’s good to find someone else who is amused with the hex “DEADBEEF” string – I use it every opportunity I can…..  I was able to verify this and it seems like a problem to me.  I moved some stuff around, and it does seem to be the inclusion of the typecast function inside of the diagram disable structure that makes a difference.  I filed a report to our LabVIEW R&D department on this (CAR ID 3YDESR3A) – hopefully it will be something they can address in future versions of LabVIEW.

Travis M
LabVIEW R&D
National Instruments
Message 2 of 6
(3,620 Views)

It looks like this is fixed in version 8.2.1.

Message 3 of 6
(3,545 Views)

Apparently that wasn't the only case where Diagram Disable behaves differently than just having the code inline.  I also was  investigating the performance of certain VIs, because I wanted to know if variant operations were faster than flatten/unflatten to/from string.

 

In the following snippet, I set the number of loop iterations to 100 and ran the VI, resulting in an Elapsed Time of ~50ms.  I then moved the 'To Variant' VI inside the Enabled structure for both cases (Disabled and Enabled), and running the VI again resulted in an elapsed time of over 2 seconds!  The source code should be identical in both cases, but it appears as though there is some optimization occuring in the first case that is not occurring in the 2nd case. It's as though in the first case, the compiler is smart enough to realize that the loop output does not change from iteration to iteration, but in the 2nd case it gets stupid.

 

So continue to beware of the Diagram Disable structure...

0 Kudos
Message 4 of 6
(3,268 Views)

Whoops - had wrong attachment. Use this snippet instead...

 

 

benchmark.png

Message Edited by wired on 06-01-2010 02:47 PM
0 Kudos
Message 5 of 6
(3,248 Views)

Hi wired,

 

This was reported to R&D (# 234215) for further investigation. Thanks for the feedback!

 

0 Kudos
Message 6 of 6
(3,187 Views)