Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

Benchmark Loop Iteration Time with Tick Count Timer

Overview

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.

 

 

Description

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.

 

 

Requirements

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.

 

Block Diagram

BD.PNG

 

**This document has been updated to meet the current required format for the NI Code Exchange. **

Eric S.
AE Specialist | Global Support
National Instruments
Comments
Member lisam88
Member

Hi,

Thanks for the great example!

I'm having problems applying this to a different application, where timer count value continues to increase after each iteration. I am looking to determine the time it takes to insert each batch (500rows) of data into a database. See block diagram below.

Database Example Timed.png