LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For loop slow when using sub vi

Solved!
Go to solution

Hello,

 

I have developed a data processing program (Main program is "Traitement.vi") in which I display the data on two graphs. Depending on whether I display the data by using classicals graphs (left graphs) or Sub Vi (on the right), the processing speed decreases with the second method (see i For Loop indicator). I do not understand this fall of speed.

 

In attached file you have the different VI and some to test it.

 

Thanks for your help.

Djamel

Download All
0 Kudos
Message 1 of 10
(1,160 Views)

Why do you have a sub VI (SSVI position curseurs vpr.vi) and then a copy of the code (SSVI 2 graphes V3.vi).

 

Straightening the wires might make the data flow faster. (It won't, but it will become a lot easier to find problems).

 

How much data is there? The sub VI (SSVI position curseurs vpr.vi) won't need a copy, the data in it's indicators will not even be updated if the VI is closed, and copies are avoided.

 

For SSVI 2 graphes V3.vi however, the indicators are now on an open front panel. This means potentially copies will be made for the indicators, and the indicators will be updated. The indicators are outputs of the VI, so even another copy might be needed.

 

If there's a lot of data, this will become significant.

0 Kudos
Message 2 of 10
(1,136 Views)

Hello,

 

The Sub VI SSVI position curseurs vpr.vi is on the first version of my program. At the end, I intend to use only the version with SSVI 2 graphes V3.vi. I put the two version only to show the slowing effect with using SSVI 2 graphes V3.vi.

 

File called harmo*.txt contain 1600 points.

 

I don(t understand your remark  "For SSVI 2 graphes V3.vi however, the indicators are now on an open front panel. This means potentially copies will be made for the indicators, and the indicators will be updated. The indicators are outputs of the VI, so even another copy might be needed."

0 Kudos
Message 3 of 10
(1,132 Views)

@Djamel_LFC wrote:

I don(t understand your remark  "For SSVI 2 graphes V3.vi however, the indicators are now on an open front panel. This means potentially copies will be made for the indicators, and the indicators will be updated. The indicators are outputs of the VI, so even another copy might be needed."


I'm not sure how to say it in another way.

 

The old solution had a sub VI, with it's front panel (usually) closed so the data will simply flow out as pointers. No data copies are made.

 

The new solution has data displayed, and connected to the connector pane. Both might cause data copies, slowing things down.

 

Again, how much data are we talking about?

 

How much slower is the new version?

0 Kudos
Message 4 of 10
(1,130 Views)

A file contains 1600 lines. So the upper graph draws 1600 values for X and same for Y (see attached file). Same thing for the lower graph.

 

The For Loop tooks 1 second in one case and about 20 seconds in the second case

0 Kudos
Message 5 of 10
(1,126 Views)

I forgot the attached file

Capture.JPG

Download All
0 Kudos
Message 6 of 10
(1,122 Views)
Solution
Accepted by Djamel_LFC

Why do you insert the VI every iteration of the loop? Wouldn't once before the loop be sufficient?

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 7 of 10
(1,120 Views)

Hello Yamaeda,

 

Many thanks.

 

It works with your solution.

 

Djamel_LFC_0-1638194731785.png

Have a good day.

Djamel

0 Kudos
Message 8 of 10
(1,077 Views)

From this we can learn that Insert VI is a costly operation, especially if not properly teamed with a RemoveVI. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 10
(1,065 Views)

@Djamel_LFC wrote:

Hello Yamaeda,

 

Many thanks.

 

It works with your solution.

 

Djamel_LFC_0-1638194731785.png

Have a good day.

Djamel


This doesn't make any sense.

 

Why is the for loop unbundling exactly the same thing N times?

 

It seems to me that executing the sub VI only once, not N times, might have some effect on execution time..

0 Kudos
Message 10 of 10
(1,024 Views)