LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the Space Constant so slow?

Obviously I'm asking comparatively since they are faster then the blink of an eye.

 

When trying to optimize some of my functions I've noticed that this one constant is really slow.

 

Here's my test VI: I simply am measuring the time it takes to append a character to a string. If the string doesn't exist, don't add anything. This also prevents the compiler from optimizing out the for loop.

 

Most cases I've averaged about 250 ms. However, if I used the space constant instead of putting a space character in a string constant. It nearly 10-fold the time it takes to nearly 2.1 seconds.

 

So I question why is this the case? I don't see why all the other constants (I checked) run at full speed, but the space constant (which I can see it's block diagram) takes significantly longer. Is this a bug?

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 1 of 7
(2,764 Views)

If you double-click the space constant, you'll notice that it is actually a VI, so there is more overhead.

Message 2 of 7
(2,759 Views)

Also note that your VI is somewhat flawed. Once you disable debugging, everything runs at 0ms, because the inner code is folded.

0 Kudos
Message 3 of 7
(2,756 Views)

Why is the space constant not inlined to remove the function call overhead?  I understand why it was done this way before in-lining was implemented.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 7
(2,749 Views)

I know it's a subVI, that's what I am questioning in this topic. Why of all the string constants is that one a subVI when all the rest are not? All the rest appear to be a raw function. (Which I'll assume is even faster then inlining)

 

As for being flawed. I wanted it to be. I don't want my for loop to be folded away. This simple test VI is so simple that it takes literally 10 million runs to have reasonible run time for compairison. If you fold it away to a single run, you can't see the effects.

Certified-LabVIEW-Architect_rgb.jpgCertified_TestStand_Architect_rgb.jpg


"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books

0 Kudos
Message 5 of 7
(2,717 Views)

bsvare wrote:

As for being flawed. I wanted it to be. I don't want my for loop to be folded away. This simple test VI is so simple that it takes literally 10 million runs to have reasonible run time for compairison. If you fold it away to a single run, you can't see the effects.


Well, it is flawed in the wrong way, because most likely the presence of a subVI will cause more complicated debugging code and the effect might be secondary. You could e.g. eliminate folding by e.g. doing a comparison of "[i] != 0" or "[i] AND 1" for the case decision. Now all variantions seem to be about the same speed (with or without debugging, resp., where debugging poses a large penalty).

0 Kudos
Message 6 of 7
(2,706 Views)

@bsvare wrote:

I know it's a subVI, that's what I am questioning in this topic. Why of all the string constants is that one a subVI when all the rest are not? All the rest appear to be a raw function. (Which I'll assume is even faster then inlining)


Because it's easy for NI's developers to add a new VI to the palettes, and difficult to add a new primitive, as described here: http://lavag.org/topic/15851-call-library-node-calling-labview/page__view__findpost__p__96183

0 Kudos
Message 7 of 7
(2,680 Views)