Script Preparation code:
x
 
function createSingleListQueue() {
    return {
        queue: [],
        enqueue(element) {
            this.queue.push(element)
        },
        dequeue() {
            return this.queue.shift()
        },
        isEmpty() {
            return this.queue.length === 0
        }
    }
}
function createDoubleListQueue() {
    return {
        input: [],
        output: [],
        enqueue(element) {
            this.input.push(element)
        },
        dequeue() {
            if(this.output.length === 0) {
                this.pivot()
            }
            return this.output.pop()
        },
        pivot() {
            this.output = this.input.reverse()
            this.input = []
        },
        isEmpty() {
            return this.input.length === 0 && this.output.length === 0
        }
    }
}
var singleQ = createSingleListQueue()
var doubleQ = createDoubleListQueue()
var queueSize = 100000
for(let i = 0; i < queueSize; i++) {
  singleQ.enqueue('testString' + i)
  doubleQ.enqueue('testString' + i)
}
Tests:
  • single

     
    for(let i = 0; i < 100000; i++) {
      singleQ.dequeue()
    }
  • double

     
    for(let i = 0; i < 100000; i++) {
      doubleQ.dequeue()
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    single
    double

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82
Chrome 114 on Windows
View result in a separate tab
Test name Executions per second
single 168.8 Ops/sec
double 130.5 Ops/sec