shlogg · Early preview
Tq-Bit @qbitme

Dynamic Array-Based Vs Circular Buffer Queue Implementations Compared

Dynamic Array-Based Queue & Circular Buffer Queue implemented in JavaScript, with benchmarking examples for performance comparison.

I briefly touched on the Queue topic of managing window scroll events in a previous article. Using a native array to handle event tasks works for small examples. When it comes to performance and scalability, it's not a good choice, because

  shift causes the array to re-index every item, which is computationally expensive
  resizing the array can cause memory fragmentation and garbage collection overhead
  arrays are optimized for indexing tasks (~= accessing items), not frequent I/O

The Queue implementations in this article still use arrays under the hood, but handle their data more efficie...