LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace Array Subset slow

Hey guys,

 

Attached I have some code that demonstrates an issue I'm having with the replace array subset function. Please look at Cursor Plot example and compare it with the speedy example.

 

In Cursor Plot Example, I'm getting the replace array subset function to take as long as .5 ms on my computer to complete. Clearly this is terrible if you need to replace lots of elements on a large array.

 

My examples require Windows! Lemme know what you guys think!

 

- Chris

0 Kudos
Message 1 of 15
(3,458 Views)

The lvlib does not contain what you might think it does.  We need the actual VIs.

0 Kudos
Message 2 of 15
(3,448 Views)
0 Kudos
Message 3 of 15
(3,440 Views)

I can only see the speedy example. Where is the cursor plot example?

0 Kudos
Message 4 of 15
(3,427 Views)

Sorry, this has all been bad. I had renamed it when I copied it, but then I didn't make the zip file out of that copy.

 

So you should compare it to "draw connected cursors".

0 Kudos
Message 5 of 15
(3,423 Views)

Remove the inner time measurements and the loop will execute in microseconds. Keep only the line time.

 

(The act of taking all these time measurements slows you down significantly.)

0 Kudos
Message 6 of 15
(3,417 Views)

While I don't disagree that the measurements take time, the reason why I'm doing those measurements is because the loop is slow even when they don't exist.

 

How long it takes to query the performance counter in windows is actually given by the QPF Resolution indicator. As you can see it's 2 orders of magnitude faster than the measurements found in the array (which is a measurement done on either side of the replace array subset vi).

0 Kudos
Message 7 of 15
(3,411 Views)

front panel explanation.png

0 Kudos
Message 8 of 15
(3,407 Views)

The QPF resolution indicator does not tell you anything, because it (1) executes in paralell to other code and (2) it does not measure the second call that contains the extra "convert to time?" code.

 

As an experimentalist, delete the inner sequence structure and keep only "replace array subset" it will be several orders of magnitude faster to draw the line.

 

 

0 Kudos
Message 9 of 15
(3,406 Views)

It's only marginally faster without the counter call. I didn't start this investigation by putting those counter calls in the main loop. I tested each portion of code (including with the profiler). It was only after testing everything else that I got to this point.

 

Do we agree that each array replacement should only take a microseconds at most? Well, without the counter calls it takes me about

 

0.000537094

 

To do one iteration. I don't see any weird buffer allocations or anything. I can't see why this is taking so long.

0 Kudos
Message 10 of 15
(3,399 Views)