Documente Academic
Documente Profesional
Documente Cultură
Dan Hedges
Overview
Understanding and Locating Performance Problems
Understanding areas in LabVIEW that affect performance
Memory copies
UI redraws
Library selection
Property Node usage
Thread friction
Reentrant VI usage
Profiling Demonstration
Select Tools>>Advanced>>Profile VIs
Unnecessary repetition
Recalculating a value rather than storing it for reuse on each iteration
Incorrect timing
Too early
Too late
Memory Management
The most common and mysterious reason for poor
performance of VIs
LabVIEW handles memory management automatically
You do not need to code when to allocate or deallocate
memory
You have less control over when memory operations occur
Execution Data
Diagram data is called
execute data
LabVIEW tries to minimize
the number of data buffers
needed
Functions that just read the
data do not need to copy it
This diagram uses about 4K of
data total
Type Conversions
Make programming easier
Explicit bullets
Implicit dots
Slow Libraries
The easy way is rarely the efficient way
Higher level VIs do many things that may not be
required
DAQ Easy I/O performs reconfiguration on each call
File primitives
Write characters to file will perform many operations
Open file, Seek file, Write block of characters, Close file
Neither are bad to use until you put them in a tight loop
Math Efficiency
LabVIEW compiler generates more efficient code in
primitives than chained operations
Math primitives with an array input are faster than
performing the array multiply using a loop
Is faster
than ->
UI Updating
Drawing to the screen is the most overlooked
performance bottleneck
Expensive math or driver calls are more obvious than
expensive drawing
Like memory management, LabVIEW tries to optimize UI
drawing but it can not perform miracles
UI Thread
Front panel updates occur in the UI thread
Execution takes place in other threads
Shared data must be protected, so LabVIEW creates
an extra copy, called a transfer buffer
UI Management
Only update indicators as often as you need
More than 10 times per second is excessive
Indicator Updating
If an indicator is placed in a loop, you should use a
timed loop or throttle the update rate
Indicators can be updated at the expiration of a timer after a
particular number of iterations
Property Nodes
Chaining together properties
Cause multiple thread swaps
Cause multiple UI updates
It is better to run the VI in the UI thread so it does not have
to swap threads on each property node
Control References
There are performance tradeoffs to using control
references
Property nodes using control references have the same
performance issues as regular property nodes
The value property has the performance characteristics of a
Property Node, not a terminal
SubVI Calls
SubVI calls are relatively expensive
Use subroutine priority if you have determined that a subVI
is the hot spot and the subVI is called rapidly
Active X controls
Automation servers created via Automation Open can be
called without swaps (if the server supports it)
Controls always are called with thread swaps
Reentrant VIs
Using reentrant VIs in two different cases
Allows a subVI to preserve state between calls
Allows a subVI to be called in parallel
Summary
1. Make your VI work
2. Run the VI Performance Profiler
3. Improve performance of key areas
Memory copies
UI redraws
Library selection
Property Node usage
Thread friction
Reentrant VI usage
Additional Resources
LabVIEW Performance and Memory Management Note
Refer to the NI Developer Zone at ni.com/zone and enter AN114 in
the Search textbox