Benchmarks

August 5, 2025 ยท View on GitHub

Analysis (TL;DR)

  • In every scenario, ChunkedQueue, introduced in this project, consumes the lowest amount of RAM
  • Performance-wise, in most scenarios, the implementations of @datastructures-js/queue and Mnemonist have the highest throughput of operations per second
  • Surprisingly, DynamicCyclicQueue, also introduced in this project, has the highest throughput in the scenario named enqueue-zigzag-dequeue

Hardware

All benchmarks were executed on a MacBook Pro A2251

Implementations being tested

The following implementations are tested in the benchmarks:

ProjectClassSymbol
lite-fifo 1.0.1 (npm, code)ChunkedQueueChunkedQueue
lite-fifo 1.0.1 (npm, code)DynamicCyclicQueueDynamicCyclicQueue
lite-fifo 1.0.1 (npm, code)LinkedQueueLinkedQueue
@datastructures-js/queue 4.2.3 (npm, code)QueueDatastructuresJsQueue
mnemonist 0.39.8 (npm, code)QueueMnemonistQueue
efficient-data-structures 0.1.310 (npm, no repo)QueueEfficientDataStructuresQueue
dsa.js 2.7.6 (npm, code)QueueDsaJsQueue

Excluded implementations

The following implementations are array based, using its push and shift methods.

These implementations do not scale, as shift has an O(n) time complexity, and are therefore excluded.

ProjectClass / Function
@supercharge/queue-datastructure (npm, code)Queue
js-data-structs (npm, code)Queue
light-queue (npm, code)Queue

Scenarios

Each benchmark scenario has its own chart to easily visualize what it tests.

buffer then gradually decrease

Enqueue a lot of items, then dequeue rate > enqueue rate, so gradually remove the items.

RAM usage

Implementation nameRAM usageDiff
ChunkedQueue28379764(baseline)
DatastructuresJsQueue77274972+172%
DynamicCyclicQueue89208348+214%
EfficientDataStructuresQueue111981042+294%
MnemonistQueue136571954+381%
DsaJsQueue142313270+401%
LinkedQueue143340408+405%

Operations per second

Implementation nameOps/secDiff
MnemonistQueue55494(baseline)
DatastructuresJsQueue52292-5%
ChunkedQueue35461-36%
DynamicCyclicQueue27125-51%
LinkedQueue21202-61%
DsaJsQueue16975-69%
EfficientDataStructuresQueue16812-69%

zigzag

Enqueue a lot, then dequeue to zero, repeatedly.

RAM usage

Implementation nameRAM usageDiff
ChunkedQueue55647214(baseline)
DatastructuresJsQueue79077452+42%
DynamicCyclicQueue118208608+112%
DsaJsQueue143181248+157%
EfficientDataStructuresQueue143378496+157%
MnemonistQueue158173512+184%
LinkedQueue209267172+276%

Operations per second

Implementation nameOps/secDiff
DatastructuresJsQueue60388(baseline)
MnemonistQueue58702-2%
LinkedQueue47190-21%
ChunkedQueue38555-36%
DynamicCyclicQueue37621-37%
EfficientDataStructuresQueue22436-62%
DsaJsQueue18806-68%

enqueue-zigzag-dequeue

Enqueue a lot, then zigzag with 1/3 of the size, then dequeue to zero.

RAM usage

Implementation nameRAM usageDiff
ChunkedQueue72885086(baseline)
MnemonistQueue79495220+9%
DynamicCyclicQueue89370588+22%
DatastructuresJsQueue96505770+32%
LinkedQueue279495582+283%
DsaJsQueue371494706+409%
EfficientDataStructuresQueue383364174+425%

Operations per second

Implementation nameOps/secDiff
DynamicCyclicQueue81741(baseline)
DatastructuresJsQueue65765-19%
MnemonistQueue65699-19%
ChunkedQueue37037-54%
LinkedQueue20902-74%
EfficientDataStructuresQueue17933-78%
DsaJsQueue17772-78%

enqueue only

Simply enqueue a lot of items, without any dequeue.

RAM usage

Implementation nameRAM usageDiff
ChunkedQueue81687646(baseline)
DatastructuresJsQueue222984634+172%
MnemonistQueue223269990+173%
DynamicCyclicQueue334902982+309%
LinkedQueue359490772+340%
DsaJsQueue431317892+428%
EfficientDataStructuresQueue431489178+428%

Operations per second

Implementation nameOps/secDiff
DatastructuresJsQueue56891(baseline)
MnemonistQueue53518-5%
ChunkedQueue32288-43%
DynamicCyclicQueue29873-47%
LinkedQueue9683-82%
EfficientDataStructuresQueue9452-83%
DsaJsQueue9334-83%

Analysis (Repeated)

  • In every scenario, ChunkedQueue, introduced in this project, consumes the lowest amount of RAM
  • Performance-wise, in most scenarios, the implementations of @datastructures-js/queue and Mnemonist have the highest throughput of operations per second
  • Surprisingly, DynamicCyclicQueue, also introduced in this project, has the highest throughput in the scenario named enqueue-zigzag-dequeue