Virus scan in progress. Please wait to download attachments.
This VI is a template for how to benchmark how long it takes a loop to iterate. This is very useful to either verify your loop is executing at the rate you desire, or to see how long it takes to perform all of the processing inside of your loop.
All this code does is calculate the difference between the time of the current iteration minus the time from the previous iteration, resulting the time spent in the previous iteration.
1. Use Tick Count (ms) to get the current time from the system clock and use it to initialize a shift register.
2. Use Tick Count (ms) inside the loop to get the current time of this iteration of the loop, and send this value to the shift register.
3. Subtract the Tick Count (ms) value from the previous iteration of the loop from the Tick Count (ms) value from the current iteration of the loop.
4. A wait (ms) VI is used here to simulate other code which takes time to execute, and is used to specify a desired loop iteration rate.
LabVIEW 2012 (or compatible)
Steps to Implement or Execute Code
1. Download and open the VI "Benchmark Loop Time_LV2012_NI Verified"
2. Specify the time the loop should wait between 2 iterations
3. Run the VI
Additional Notes or References
Depending on your application and code, it may be necessary to add a single frame of a sequence structure in order to ensure the Time Count (ms) VI always executes before all of the rest of your code inside of your loop. This is necessary to ensure consistent measurements.
**This document has been updated to meet the current required format for the NI Code Exchange. **
Eric S. AE Specialist | Global Support National Instruments
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.