LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to optimize the execution speed of a specific piece of code?

Solved!
Go to solution

Is there any structure that can wrap the code to make the code have the top priority when the code is executed?

Thanks,

0 Kudos
Message 1 of 9
(4,138 Views)

Use an FPGA Target...

Can't be more specific with your vague question.

Vincent

0 Kudos
Message 2 of 9
(4,127 Views)

Yes. It is called Timed Sequence.

However, there are a lot of specific rules to follow when using timed structures. Breaking that rules can lead to performance degregation up to undesired runtime behavior. So please make sure to know and understand those rules before starting to meddle with priorities by using timed structures.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 9
(4,122 Views)

If you're using a cRIO or other embedded targets (e.g. PXI), then you might be able to use timed loops on RT or code on an FPGA. On Windows, neither of those suggestions are useful.

 

You can set the 'priority' of a SubVI but it is unlikely to make a significant difference.

 

The most important thing you can do is to optimise that specific piece of code - which we can only help you with if you share it with us. There are some basic guidelines (e.g. avoid property nodes, avoid memory allocations etc.) but without knowing what your code is doing, or how you have implemented it, it's impossible to tell.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 9
(4,087 Views)

Appreciate above replies.

I think I don't show my question very clearly,thus complicats the question.

My application is simple,just a UI operation code as below.

This code is highlighting a row in a table on Mouse Move Event.The problem is that when the mouse moves just inside a row,the row will blink,which is not expected.The reason is that it takes about 10ms between the two property node of CellBGColor.My whole software is a little complicated and it has some background code running always.

I tried the code in a simple demo VI ,and it only takes 2ms ,so it won't blink.

So I have to prioritize the code to make sure it executes fast enough.

 

code.jpg

 

0 Kudos
Message 5 of 9
(4,065 Views)

Property Nodes for front panel items are just slow because they force thread swapping to the UI thread and redraw the front panel each time you write to one.  About the only thing you can do to speed it up is to use the Defer Front Panel Updates.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 9
(4,054 Views)

You should change color only if the mouse changes row. So include code to check "previous row vs. current row" and recolor only if that is not the same.

I'm not sure about performance impact but it might be better to not recolor the whole table, but only rows which are "used". That means if mouse pointer changes row, you color the "old row" in default color and the "new row" in the highlighted one. It also might be beneficial to defer panel updates until both recolor commands are being issued to only get a single redraw. This could also prevent blinking to a certain degree...

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 7 of 9
(4,053 Views)
Solution
Accepted by topic author avater

Set the 'defer panel updates' property of the VI front panel to true before your code starts, and set it back to false afterwards. That should stop the table from blinking when you clear and change the colour and will significantly speed up the updates.

 

Here's an example:

RedrawSpeed.png


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 8 of 9
(4,047 Views)

Works awesome!

Thanks.

0 Kudos
Message 9 of 9
(3,985 Views)