80 likes | 190 Views
Circular Buffer Architectures Performance Comparison of Conventional Circular Data Buffers versus Lossy Que Circular Data Buffers. Colorado ALARM User Group 09 December 2010 Steve Solga | Electromecha LLC. Conventional Circular Buffer. Initializing CB
E N D
Circular Buffer ArchitecturesPerformance Comparison of Conventional Circular Data Buffers versus Lossy Que Circular Data Buffers Colorado ALARM User Group 09 December 2010 Steve Solga | Electromecha LLC
Conventional Circular Buffer • Initializing CB • LV2 Style Functional Global with the data array persisting in an un-initialized shift register. • Initialize a data array of prescribed dimensions in order to allocate total memory required for circular buffer once. • Adding to CB • Use LabVIEW’s native Array Subset.vi and Replace Array Subset.vi to replace pre-initialized data subsets with the real data subsets. • Need to keep track of an array index pointer in order to implement the rotational data buffer.
Conventional Circular Buffer • Getting CB • Get operations are fast because array construction and organization have already been performed. • Need to rotate array according to pointer in order to get full data buffer in chronological order.
Lossy Que Circular Buffer • Initializing CB • LV2 Style Functional Global with Queue reference persisting in an uni-initialized shift register. • Obtain Queue of prescribed data type and size. • Add to CB • Use LabVIEW’s native Lossy EnqueueElement.vi to add a data element to the Circular Buffer. • No need to keep track of an array index pointer since the queue manages the location automatically.
Lossy Que Circular Buffer • Getting CB • Getting the entire data history requires concatenating all the elements in the Lossy Queue. • This of course requires pre-allocating a data array and replacing initialized array subsets with data elements from the Lossy Queue.
Conclusions | Contrasts • Lossy Que Circular Buffers • Super easy to program on the front end by simply Obtaining a Queue. • Code is simple and lean to Add data to, Flush, or get Status of Lossy Queue. • All data types are already conveniently managed by the Queue Functions. • No need to worry about where the oldest data is in the Circular Buffer when getting the entire history. • Work and processor time required on the back end if you need the entire Circular Data Buffer at once. • Conventional Circular Buffers • Nearly all of development time is on the Front End in programming the replacement of data subsets in the pre-initialized data buffer. • Coding one is always a fun brain teaser in trying to get the array index pointer logic correct when adding data elements. • Extra code required to manage where the pointer is in order to rotate buffer correctly when reading the entire Circular Data Buffer. • Getting the entire Data Buffer is fast since all of the data array construction and organization has already been performed in the Add State.
Thanks! • This presentation and it’s corresponding code are on the Alarm User Group NI Community site. • Thanks Dave Thomson for oversight and a second set of eyes. • Thanks Colorado Alarm Group. • Thanks NI for awesome products and support.