mirror of
https://github.com/bcomnes/deploy-to-neocities.git
synced 2026-01-17 06:56:30 +00:00
35 lines
709 B
JavaScript
35 lines
709 B
JavaScript
const FastFIFO = require('./')
|
|
const FIFO = require('fifo')
|
|
|
|
run(new FIFO(), 'fifo')
|
|
run(new FastFIFO(), 'fast-fifo')
|
|
run(new FIFO(), 'fifo')
|
|
run(new FastFIFO(), 'fast-fifo')
|
|
|
|
function run (q, prefix) {
|
|
const runs = 1024
|
|
|
|
console.time(prefix + ' bulk push and shift')
|
|
|
|
for (let j = 0; j < 1e5; j++) {
|
|
for (let i = 0; i < runs; i++) {
|
|
q.push(i)
|
|
}
|
|
for (let i = 0; i < runs; i++) {
|
|
q.shift()
|
|
}
|
|
}
|
|
|
|
console.timeEnd(prefix + ' bulk push and shift')
|
|
console.time(prefix + ' individual push and shift')
|
|
|
|
for (let j = 0; j < 1e5; j++) {
|
|
for (let i = 0; i < runs; i++) {
|
|
q.push(i)
|
|
q.shift()
|
|
}
|
|
}
|
|
|
|
console.timeEnd(prefix + ' individual push and shift')
|
|
}
|