Files
klz-cables.com/.pnpm-store/v10/files/cb/c5eefa17cfb1bbc32163508eecf30dfa73cbca1d6d5bef4023170fe7e4a421f2744e13544d2cecdae0efdcfd1dbbd4b329437ca4012eab43abce77de24f443
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

86 lines
1.9 KiB
Plaintext

'use strict'
const bench = require('fastbench')
const SonicBoom = require('sonic-boom')
const ThreadStream = require('.')
const Console = require('console').Console
const fs = require('fs')
const { join } = require('path')
const core = fs.createWriteStream('/dev/null')
const fd = fs.openSync('/dev/null', 'w')
const sonic = new SonicBoom({ fd })
const sonicSync = new SonicBoom({ fd, sync: true })
const out = fs.createWriteStream('/dev/null')
const dummyConsole = new Console(out)
const threadStreamSync = new ThreadStream({
filename: join(__dirname, 'test', 'to-file.js'),
workerData: { dest: '/dev/null' },
bufferSize: 4 * 1024 * 1024,
sync: true
})
const threadStreamAsync = new ThreadStream({
filename: join(__dirname, 'test', 'to-file.js'),
workerData: { dest: '/dev/null' },
bufferSize: 4 * 1024 * 1024,
sync: false
})
const MAX = 10000
let str = ''
for (let i = 0; i < 100; i++) {
str += 'hello'
}
setTimeout(doBench, 100)
const run = bench([
function benchThreadStreamSync (cb) {
for (let i = 0; i < MAX; i++) {
threadStreamSync.write(str)
}
setImmediate(cb)
},
function benchThreadStreamAsync (cb) {
threadStreamAsync.once('drain', cb)
for (let i = 0; i < MAX; i++) {
threadStreamAsync.write(str)
}
},
function benchSonic (cb) {
sonic.once('drain', cb)
for (let i = 0; i < MAX; i++) {
sonic.write(str)
}
},
function benchSonicSync (cb) {
sonicSync.once('drain', cb)
for (let i = 0; i < MAX; i++) {
sonicSync.write(str)
}
},
function benchCore (cb) {
core.once('drain', cb)
for (let i = 0; i < MAX; i++) {
core.write(str)
}
},
function benchConsole (cb) {
for (let i = 0; i < MAX; i++) {
dummyConsole.log(str)
}
setImmediate(cb)
}
], 1000)
function doBench () {
run(function () {
run(function () {
// TODO figure out why it does not shut down
process.exit(0)
})
})
}