This commit is contained in:
Bret Comnes
2020-02-12 16:58:30 -07:00
parent 383cb4ca53
commit 80459935e1
98 changed files with 9972 additions and 1 deletions

34
node_modules/fast-fifo/bench.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
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')
}